users@glassfish.java.net

Re: JavaMail converts UTF-8 chars to question marks

From: <glassfish_at_javadesktop.org>
Date: Sun, 08 Jun 2008 17:05:18 PDT

The message takes a path through many pieces of software before it comes
back to you and is stored on your disk. Any of those pieces of software could
be causing the problem. The challenge is to isolate the cause of the problem
to one of those pieces of software.

Before you send the message, or instead of sending the message, do a
msg.writeTo(new FIleOutputStream("msg.txt"));

That's the message that JavaMail is sending to your server. If that message
is correct, the problem is not in JavaMail.

Generally a message stored on disk is *not* going to use the UTF-8 charset.
Usually it will use the ASCII charset and any non-ASCII body parts will be encoded
(e.g., using quoted-printable or base64) into ASCII characters. Possibly Thunderbird
is saving the message using the OS charset and is saving the body parts in 8bit
format. If you read such a message using the wrong charset, you'll get the wrong
data.

If you still can't figure this out, send me a copy of the message you send
(msg.txt above) and a copy of the message you receive. Send them to
javamail_at_sun.com and I'll help you figure out what's wrong.
[Message sent by forum member 'shannon' (shannon)]

http://forums.java.net/jive/thread.jspa?messageID=279024