使用驼峰邮件发送时,Outlook 2016 将无法正确显示带有文本/html 内联附件的电子邮件。
相同的电子邮件在苹果邮件等其他邮件客户端中正确显示。
我已经尝试交换邮件本身的内容类型,以及附件的内容类型。
当内容类型设置为 text/rich 时,将显示内联附件,但电子邮件的正文最终会作为常规附件。
如果电子邮件的内容类型是 text/html,则正文将正确显示,但附件最终会作为常规附件而不是内联附件。
添加附件的处理器:
String emailContent = emailBody.getContent().toString();
byte[] emailContentByte = emailContent
.getBytes("UTF-8");
// add the file as an attachment to the exchange with a text/html format.
exchange.getIn().addAttachment("cid:http-email", new DataHandler(
(DataSource) new ByteArrayDataSource(emailContentByte,
"text/html")));
骆驼 smtp 端点和标头:
.setHeader("contentType", constant("text/html"))
.process(new AttachmentBuilder())
.to("velocity:{{mail.template}}?encoding=UTF-8")
//send the exchange to the specified email address.
.toD("smtp://{{mail.smtp.host}}:{{mail.smtp.port}}"
+ "?from={{mail.smtp.from}}"
+ "&to={{mail.smtp.to}}"
+ "&useInlineAttachments=true")