How do I encode the string that I want to send so that the message is mail safe?

John Zukowski

When you call setText(message) on the MimePart/MimeMessage this will encode the string for you using the platform's default character set. If you know the character set, you can call setText(message, charset), which will be faster for larger messages.