wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Java Mail: How to display sender's name? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail: How to display sender Watch "Java Mail: How to display sender New topic
Author

Java Mail: How to display sender's name?

Sherry Chandra
Greenhorn

Joined: May 13, 2004
Posts: 4
Hi everyone,
I am new in Java Mail api and i am having a simple problem.
How can i specify the sender name rather then his email address while sending mail.
When i am sending the mail the recepient sees the sender's name as my full email address and not my name.
I would like to specify that name in the mail program.
Hoping for a reply
Thanks
Sharath
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There is an addFrom(Address[] addresses) method on javax.mail.Message (and more usefully its concrete subclass MimeMessage). Normally you'd add addresses as javax.mail.InternetAddress which has some loose SMTP address validation, conveniently it is loose enough to allow for any string - so you can add a from address which is "Sherry Chandra" easily enough. However remember to set the replyTo address as a valid address - otherwise people will not be able to rely (unless you are using something like Exchange an only expect to be emailing to other people on the same Exchange server).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
jesudian selvaraj
Greenhorn

Joined: May 31, 2012
Posts: 1
Thanks for your reply. But this way it 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”. When we send a mail from outlook or browser it works, but not in javamail.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
That's a function of the email client, not the JavaMail API. Note that JavaMail has no provisions for accessing Outlook and/or Exchange-specific functionality.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Mail: How to display sender's name?
 
Similar Threads
[JavaMail]: How to hide sender's email address?
Verification of Email Address
javax.mail Sender's Name
Sender's Address
Sending a message from a sender's email id to receivers email id without authentication