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
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).
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.