【发布时间】:2019-07-07 12:54:53
【问题描述】:
使用驼峰邮件发送时,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")));
camel 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")
【问题讨论】:
-
我暂时解决了这个问题,通过将内容与电子邮件合并而不是创建内联附件,我觉得这不是一个干净的解决方案。
标签: apache-camel email-attachments apache-camel-mail