how can i add recipient name in "To" field of the email

G

gupta.divyendu

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
 
E

Eric Sosman

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.

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 <[email protected]>
 
N

Nigel Wade

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.

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" <[email protected]>

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.

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.

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"));
 
M

Martin Gregorie

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.
See InternetAddress and MimeMessage.setRecipients().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top