Aug 26

When specifying an email address using JavaMail you can not only specify actual email address of the person, but also their name if required. The InternetAddress class is used to represent an email address which includes support for specifying both the email address and the personal name.

There are two ways this can be done, firstly the RFC822 address syntax can be used to specify both in one string.

message.setFrom(new InternetAddress("Joe Smith <>"));

Or alternatively a constructor is available to specify the two separately

message.setFrom(new InternetAddress("", "Joe Smith"));

written by objects \\ tags: , ,

Array ( ) 4 Responses to “How to include sender name using JavaMail”

  1. Chun li Says:

    I follow your web page for quite a lengthy time and truly tell that your content articles often prove to be of a high value and quality for readers.

  2. Sidney Says:


  3. Chutney Says:

    Both ways doesn’t pick the contact details from the exchange server. It directly hardcodes the contact that we specify. Is there a way to pick the contact from the server so that clicking on the contact will pop up the complete contact details of the from address in outlook. It works fine for “to address” but not the same way for “from address”. But when we send a mail from outlook or browser it works.

  4. sundar Says:

    it worked thanku 🙂

Leave a Reply

You must be logged in to post a comment.