0
votes

Outlook 2016 will not display an Email with a text/html Inline Attachment correctly when sent with camel-mail.

The same email is displayed correctly in other mail clients like apple mail.

I have already tried swapping the content type of the mail itself, as well as the content type of the attachment.

When the content type is set to text/rich the inline attachment will display, but the body of the email ends up as a regular attachment.

If the content type of the email is text/html the body will display correctly, but the attachment ends up as a regular attachment and not inline.

The Processor that adds the attachment:

  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")));

The camel smtp endpoint and headers:

        .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")
1
I have temporarily solved the issue, by merging the content with the Email instead of creating an Inline Attachment, I don't feel this is a clean solution though.user9338894

1 Answers

2
votes

I think the content-type of the whole mail message should be Content-Type: multipart/related.

text/html would be the content-type of the individual message parts.

Perhaps this q/a from stackoverflow helps. It is about images but the main point is the content-type of the surrounding message.