How to send html email to outlook from Java

前端 未结 8 2052
忘掉有多难
忘掉有多难 2021-02-04 04:06

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         


        
8条回答
  •  灰色年华
    2021-02-04 04:53

    Change this To:

    message.setContent(new String(sBuffer.toString().getBytes(), "iso-8859-1"), "text/html; charset=\"iso-8859-1\"");
    

    The content char set need to be set, I don't see why the content itself. Should rather be:

    message.setContent(sBuffer.toString(), "text/html;charset=iso-8859-1");
    

提交回复
热议问题