How do I send an HTML email?
Set content type. Look at this method.
message.setContent("<h1>Hello</h1>", "text/html");
As per the Javadoc, the MimeMessage#setText()
sets a default mime type of text/plain
, while you need text/html
. Rather use MimeMessage#setContent()
instead.
message.setContent(someHtmlMessage, "text/html; charset=utf-8");
For additional details, see:
- GMail Media Queries
- GMail CSS Design
- CSS support in mail clients