Forums Register Login

Java Mail: How to display sender's name?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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).
+Pie Number of slices to send: Send
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.

1
+Pie Number of slices to send: Send
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.
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 9589 times.
Similar Threads
javax.mail Sender's Name
[JavaMail]: How to hide sender's email address?
Verification of Email Address
Sending a message from a sender's email id to receivers email id without authentication
Sender's Address
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:57:40.