views:

41

answers:

2

How do I get the charset from javax.mail.Message object?

+1  A: 

The MimeMessage class has a method which returns the transfer encoding.

Edit: But, as Aaron correctly points out, you normally shouldn't have to worry.

Henning
+3  A: 

The mail API should convert the data to Unicode for you, so at the time when you can call the getter for the text, the original charset shouldn't matter.

But if you really need it, then call getContentType() and look for charset=. If it's there, then that's the encoding. If it isn't there, then the charset should be US-ASCII (7 bit).

Aaron Digulla
That`s exactly what I`ve been looking for, thank you.
folone