Показывать только от «имени», а не от адреса электронной почты в JavaMailSender и клиенте Outlook - PullRequest
3 голосов
/ 20 января 2012

Я использую Spring MimeMessageHelper и JavaMailSender. Можно ли показывать только имя отправителя сообщения, а не адрес при отправке электронной почты, почтовый клиент (Outlook).

Спасибо!

1 Ответ

6 голосов
/ 21 января 2012
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8");
// you can either do it this way with a regular string
message.setFrom("John Smith <john@example.com>");

// or this way with an InternetAddress
message.setFrom(new InternetAddress("john@example.com", "John Smith"));
...