【发布时间】:2016-04-11 23:08:07
【问题描述】:
我正在使用 java 邮件 api 向 Outlook 发送邮件。我可以发送纯文本和 html 内容邮件,但是当我将内容类型设置为 text/richtext 但我只接收纯文本邮件。
任何机构都可以建议如何发送富文本邮件吗?这是我尝试过的:
// the parent or main part if you will
Multipart mainMultipart = new MimeMultipart("related");
// this will hold text and html and tells the client there are 2 versions of the message (html and text). presumably text
// being the alternative to html
Multipart htmlAndTextMultipart = new MimeMultipart("alternative");
// set html
MimeBodyPart htmlBodyPart = new MimeBodyPart();
htmlBodyPart.setContent("Hi", "text/richtext");
htmlAndTextMultipart.addBodyPart(htmlBodyPart);
MimeBodyPart htmlAndTextBodyPart = new MimeBodyPart();
htmlAndTextBodyPart.setContent(htmlAndTextMultipart);
mainMultipart.addBodyPart(htmlAndTextBodyPart);
message.setContent(mainMultipart);
【问题讨论】:
-
如果您添加一些富文本格式会有所帮助 - 否则差异不存在。
-
是的,但是 Outlook 在邮件顶部显示内容类型。因此我们可以轻松识别内容类型。
-
您的文本是纯文本。你看过outlook中的标题吗?
-
我的意思是,如果我将内容类型作为富文本发送,无论我发送什么,Outlook 都应该在邮件顶部的括号中显示内容类型富文本,例如 Message-(Rich text)
-
检查标题。您的客户如何展示是完全不同的故事
标签: java jakarta-mail