How to send html email to outlook from Java

前端 未结 8 2053
忘掉有多难
忘掉有多难 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:34

    I used the following code:

    mimeBodyPart1.setDataHandler(new DataHandler(new ByteArrayDataSource(messageBody, "text/html; charset=utf-8")));
    multiPart.addBodyPart(mimeBodyPart1);
    message.setContent(multiPart, "text/html; charset=utf-8");
    

    Now, Outlook displays in html format.

提交回复
热议问题