【问题标题】:How to send an email with an Inline Attachment to outlook with camel-mail如何使用骆驼邮件将带有内联附件的电子邮件发送到 Outlook
【发布时间】: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


【解决方案1】:

我认为整个邮件消息的内容类型应该是Content-Type: multipart/related

text/html 将是各个消息部分的内容类型。

也许this q/a from stackoverflow 有帮助。它是关于图像的,但重点是周围消息的内容类型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-09
    • 2011-11-22
    • 2015-09-09
    相关资源
    最近更新 更多