problem when sending non english characters through Java Mail API
Badari Kandepi
Greenhorn
Joined: Feb 01, 2013
Posts: 4
posted
0
Hi ,
I am trying to send some non english charactes using Java Mail API.
sending Cancúnreenvíe but i receviced like Canc??nreenv??e .
replacing question marks .
Can any one please give the solution for this?
Thanks in Advance
Badari Kandepi
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
Sounds like the encoding isn't set correctly somewhere along the way. How are you handling that?
You need to specify the charset. I believe the following will work:
Notice how I don't convert the body into a byte[] as that shouldn't be necessary. If it is however, you need to create a String with a specified encoding as well. In Java 7:
In Java 6 or before you need to use a String for the charset name and catch / rethrow the UnsupportedEncodingException, or create a Charset:
Rob Spoor wrote:You need to specify the charset. I believe the following will work:
Notice how I don't convert the body into a byte[] as that shouldn't be necessary. If it is however, you need to create a String with a specified encoding as well. In Java 7:
In Java 6 or before you need to use a String for the charset name and catch / rethrow the UnsupportedEncodingException, or create a Charset:
it is not working for me . here msg.getBody() returns ByteArrayOutputStrem.please suggest me accordingly