Java Mail API - Encoding problems

    MimeMessage message = new MimeMessage(session);
    message.setSubject(subject, "UTF-8");
    message.setText(body, "UTF-8");

So one has to set the character encoding for both, body and subject.


Addendum because of comment of @bartac

For the corresponding MimeBodyPart do a setHeader("Content-Type", "text/plain; charset=UTF-8").


You should use setText(String text, String charset) or setText(String text, String charset, String subtype) to set the text body with a specific encoding.

MimeUtility.encodeText() is not meant for body text, but only for encoded text in headers (and then only for headers set with setHeader or addHeader).