Reputation: 325
I'm using in a java application the javax.mail.internet.MimeMessage
to send mail message via javax.mail
library.
In the message creation class I use something like:
message.setFrom(new InternetAddress("[email protected]"));
The message when received show in the message header:
From: <[email protected]>
with any mail client software is possible to specify the 'displayed' sender, and in that case the header looks like:
From: Name Surname <[email protected]>
where "Name Surname" is a free string, like also "CompanyName commercial office", and it is what in general mail client shows about message sender.
How can I set the 'displayed' sender into the message object? message.setFrom(String s)
doesn't work.
Upvotes: 1
Views: 570
Reputation: 4899
Just use the constructor with the personal parameter:
message.setFrom(new InternetAddress("[email protected]","Name Surname"));
Upvotes: 2