I\'m trying to send an email in html format using JavaMail but it always seems to only display as a text email in Outlook.
Here is my code:
try
{
P
message.setContent(new String(sBuffer.toString().getBytes(), "iso-8859-1"), "text/html; charset=iso-8859-1");
Should solve your problem (removed \"
characters).
html.setContent(htmlBody, "text/html");
html.setHeader("MIME-Version" , "1.0" );
html.setHeader("Content-Type" , html.getContentType() );
setContent
and setHeader("Content-Type", String)
do the same thing - is it possible that html.getContentType()
is returning something other than text/html
?
Expanding based on comment and @PhilLho & @erickson's answer (geez, I must type slowly), use:
MimeMultipart content = new MimeMultipart("alternative")