1

The body of the message I receive is html structured but the type of the message says text/plain. In javax.mail getContent() returns plain text instead of html structured text. Even getBodyPart() returns just text.

Is there a way of actually extracting the html formatted message body from an email message marked as text/plain?

Object content = inMessage.getContent();
MimeMultipart mimeMultipart = (MimeMultipart) content;
BodyPart bodyPart = mimeMultipart.getBodyPart(i);
String cnt = (String) bodyPart.getContent());

cnt is a plain text instead of being html formatted. I know it is html because Outlook reads it as html and ViewSource in Outlook is html email.

Thank you

4

1 回答 1

0

多部分消息可能是包含纯文本和 html 部分的多部分/替代方案。请参阅此 JavaMail FAQ 条目

于 2013-05-27T18:34:36.547 回答