与骆驼邮件一起发送时,Outlook 2016将无法正确显示带有text / html内联附件的电子邮件。
同一封电子邮件在其他邮件客户端(如Apple Mail)中正确显示。
我已经尝试过交换邮件本身的内容类型以及附件的内容类型。
当内容类型设置为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")
答案 0 :(得分:2)
我认为整个邮件的内容类型应为Content-Type: multipart/related
。
text/html
将是各个消息部分的内容类型。
也许this q/a from stackoverflow会有所帮助。它与图像有关,但要点是周围消息的内容类型。