Skip to Main Content

Java SE (Java Platform, Standard Edition)

Mail with Unicode Characters (Cyrillic) in Subject

843810Jun 10 2009 — edited Jul 22 2011
Hello,

how can we send an email with Unicode characters (more specifically, Cyrillic) in the Subject line, using java.awt.Desktop?
Here is the small piece of code:
...
if (!Desktop.isDesktopSupported())
    return false;
Desktop desktop = Desktop.getDesktop();
if (!desktop.isSupported(Desktop.Action.MAIL)) 		    
    return false;

String sURI = "john.doe@company.com?SUBJECT=\u041f\u043e\u0437\u0434\u0440\u0430\u0432";

URI uri = new URI("mailto", sURI, null);
desktop.mail(uri);
...
MS Outlook will pop open but will show question marks in the subject line (???????).

When I tried to encode the Unicode string with URLEncoder (or with my own base64 encoder), the subject line shows that string just as it is (encoded).
String sURI = "john.doe@company.com?SUBJECT=" + URLEncoder.encode("\u041f\u043e\u0437\u0434\u0440\u0430\u0432", "utf-8");
Can anything be done here? The similar question is applicable also for body of the email.

Regards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2011
Added on Jun 10 2009
6 comments
1,211 views