Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Mail: How to display sender's name?

 
Sherry Chandra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
jesudian selvaraj
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2745
38
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic