Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java邮件消息体是html,但类型是文本/纯读html_Html_Jakarta Mail_Message - Fatal编程技术网

Java邮件消息体是html,但类型是文本/纯读html

Java邮件消息体是html,但类型是文本/纯读html,html,jakarta-mail,message,Html,Jakarta Mail,Message,我收到的消息的主体是html结构的,但是消息的类型是text/plain。在javax.mail中,getContent()返回纯文本,而不是html结构化文本。甚至getBodyPart()也只返回文本 有没有办法从标记为text/plain的电子邮件中提取html格式的邮件正文 Object content = inMessage.getContent(); MimeMultipart mimeMultipart = (MimeMultipart) content; BodyPart bod

我收到的消息的主体是html结构的,但是消息的类型是text/plain。在javax.mail中,getContent()返回纯文本,而不是html结构化文本。甚至getBodyPart()也只返回文本

有没有办法从标记为text/plain的电子邮件中提取html格式的邮件正文

Object content = inMessage.getContent();
MimeMultipart mimeMultipart = (MimeMultipart) content;
BodyPart bodyPart = mimeMultipart.getBodyPart(i);
String cnt = (String) bodyPart.getContent());
cnt是纯文本,而不是html格式。我知道它是html,因为Outlook将其读取为html,Outlook中的ViewSource是html电子邮件


谢谢

多部分消息可能是一个包含纯文本和html部分的多部分/备选方案。看