Send javax.mail.internet.MimeMessage to a recipient with non-ASCII name?

Posted by phyzome on Stack Overflow See other posts from Stack Overflow or by phyzome
Published on 2010-04-16T22:46:08Z Indexed on 2010/04/16 22:53 UTC
Read the original article Hit count: 248

Filed under:
|
|
|
|

I am writing a piece of Java code that needs to send mail to users with non-ASCII names. I have figured out how to use UTF-8 for the body, subject line, and generic headers, but I am still stuck on the recipients.

Here's what I'd like in the "To:" field: "????????????" <[email protected]>. This lives (for our purposes today) in a String called recip.

  • msg.addRecipients(MimeMessage.RecipientType.TO, recip) gives "?????S]" <[email protected]>
  • msg.addHeader("To", MimeUtility.encodeText(recip, "utf-8", "B")) throws AddressException: Local address contains control or whitespace in string ``=?utf-8?B?IuOCpuOCo+OCreODmuODh+OCo+OCouOBq+OCiOOBhuOBk+OBnSIgPA==?= =?utf-8?B?Zm9vQGV4YW1wbGUuY29tPg==?=''

How the heck am I supposed to send this message?

© Stack Overflow or respective owner

Related posts about unicode

Related posts about email