Discussions
Categories
- 197.1K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.7K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 555 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.3K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 466 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Mail with Unicode Characters (Cyrillic) in Subject

843810
Member Posts: 46,938
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:
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).
Regards
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 = "[email protected]?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 = "[email protected]?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
-
In the meantime, I had to solve my problem one way or another, and the only thing that came up to my mind was to use JavaMail API.
It is not quite what I was hoping for, because it doesn't provide opening of default e-mail client on local machine, but at least it can send e-mail with Unicode characters in the subjects line, recipient addresses, etc.
Make a new message using JavaMail and then set it's properties in a fairly simple manner, like this:message.setSubject( MimeUtility.encodeText("+ ... some Unicode text with Cyrillic symbols ... +", "UTF-8", "B") );
I'd still like to see if there are any suggestions on how to do the similar thing with java.awt.Desktop.
Regards,
PS -
I exactly followed your code, however, the subject still shows unicode, not the Chinese I expected.
message.setSubject(MimeUtility.encodeText("亲爱的用户", "UTF-8", "B"));
Anything suggestions? -
My suggestion would be
message.setSubject("亲爱的用户");
-
I tried that before and it did not work. The subject still shows unicode, not Chinese.
Any other suggestions? -
My suggestion would be to have posted the question in the JavaMail forum in the first place. However now my suggestion is to go over there and search for answers.
-
Tried and could not find any answers. If you find one, please let me know. Thanks,
This discussion has been closed.