Hi
I am using javamail to send multiple emails (one email is send to one
person only).
But I would that the recipient when receive this email, in the "To"
column of his email software, instead of the email id where the email
was sent, his name should be shown.
I knew the recipient name but I do not know how to put this name in
the email.
for example, when we open Outlook Express and click the view of any
folder. There is a column "To" and "From". In "To", I would like to
show his name not the email id and in "From" my name should be
displayed not my email id.
Please guide.
Divyendu
Eric Sosman - 12 Nov 2007 17:10 GMT
gupta.divyendu@gmail.com wrote On 11/12/07 11:44,:
> Hi
>
[quoted text clipped - 12 lines]
> show his name not the email id and in "From" my name should be
> displayed not my email id.
If I understand what you ask, I think all you need
to do is enclose the E-mail address in < > and append
it to the name:
Kublai Khan <kkhan@xanadu.not>

Signature
Eric.Sosman@sun.com
Nigel Wade - 12 Nov 2007 17:35 GMT
> Hi
>
[quoted text clipped - 4 lines]
> column of his email software, instead of the email id where the email
> was sent, his name should be shown.
There is no way that you can guarantee to be able to do this. What gets shown in
the email client is up to the email client, and you can't control that.
However, you can improve your chances by formatting the sender and recipient
addresses in a RFC822 format. One acceptable format is:
"name" <user@some.domain>
where "name" is the name of the recipient.
Many email clients will display the quoted name in preference to the actual
email address.
> I knew the recipient name but I do not know how to put this name in
> the email.
[quoted text clipped - 5 lines]
>
> Please guide.
Look up the documentation for javax.mail.Message.setRecipient() and
javax.mail.Message.setFrom(). These methods take a
javax.mail.internet.InternetAddress as argument and that class has constructors
which allow you to use the full RFC822 format email and personal address
fields:
message.setFrom(new InternetAddress("email", "personal"));

Signature
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
Martin Gregorie - 12 Nov 2007 18:23 GMT
> Hi
>
[quoted text clipped - 14 lines]
>
> Please guide.
See InternetAddress and MimeMessage.setRecipients().

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |