更新时间:2023-01-08 15:54:41
你需要包装你的 MimeMultipart
另一个
MimeBodyPart
,使用 MimeBodyPart.setContent(Multipart mp)
方法。然后,您可以将 MimeBodyPart
添加到 mixedPart
Object:
You need to wrap your MimeMultipart
in another MimeBodyPart
, using the MimeBodyPart.setContent(Multipart mp)
method. Then you can add the MimeBodyPart
to the mixedPart
Object:
MimeMultipart alternativeMultipart = new MimeMultipart("alternative");
BodyPart textPart = new MimeBodyPart();
textPart.setContent("someText", "text/plain");
alternativeMultipart.addBodyPart(textPart);
BodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent("someHtml", "text/html");
alternativeMultipart.addBodyPart(htmlPart);
MimeBodyPart alternativeBodyPart = new MimeBodyPart();
alternativeBodyPart.setContent(alternativeMultipart);
MimeMultipart mixedMultipart = new MimeMultipart("mixed");
mixedMultipart.addBodyPart(alternativeBodyPart);
MimeBodyPart textPart1 = new MimeBodyPart();
textPart1.setContent("someOtherText", "text/plain");
mixedMultipart.addBodyPart(textPart1);