Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
gupta.divyendu@gmail.com - 12 Nov 2007 16:44 GMT
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       |



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.