Support Images in Outgoing Emails in D365FO

How to use images in outgoing emails

In general, there are 3 ways to embed images in your emails:

  • Inline embedded CID images
  • Embed an image using CID (Content-ID) in the HTML email body, while attaching it to mail message (as Linked Resource).
    Pros: Does not depend on external sources.
    Cons: Has to be done programmatically and increases the email size.

  • Inline embedded Base64 encoded images
  • Embed an image directly in the HTML email body as the Base64 encoded string.
    Pros: Does not depend on external sources.
    Cons: Has to be done programmatically, might be blocked in some email clients (ex. Gmail web client) and increases the email size. Email body source becomes quite unreadable.

  • Linked images (specified via URLs)
  • Embed an image using its full URL path in the HTML email body; the image needs to be stored on a public cloud storage.
    Pros: Minimal email size.
    Cons: Might be blocked in some email clients and requires download from external servers.

In the screenshots below, see how all 3 image embedding techniques look in practice. Generally CID image are most aproprite for general use.

Are images supported in the email body of outgoing emails in D365FO

When it comes to emailing reports in D365FO, there is no support for the email body OOTB, so we can't really talk what's supported and what's not 😀.

On the other hand, for outgoing emails based on Organization and System email templates sent out from D365FO using Email processing (Batch email sending status and Email distributor batch), you can edit the email body and use static Linked images OOTB.

Linked images are not as useful for sending emails in D365FO as CID or Base64 images as only the latter can be dynamic and fetched from the D365FO database (e.g. Product images, Worker image, Company logo).

If you decide to customize your code and support email messages with CID or Base64 encoded images, note that Docentric versions before 3.4.8.4 have a problem with CID images when emails are sent with D365FO Exchange or Graph email providers. Older versions embed CID images as linked resources on alternate view which is not supported by these email providers. Since version 3.4.8.4 CID images are embeded as (hidden) inline attachments which works fine with all email providers and email clients.

Use email images in Docentric

Docentric Free Edition enables emailing reports with the email body, supporting all 3 types of embedded images (CID, Base64 and Linked images). Additionally, you can use Email processing for emailing reports or preconfigured Report Email templates. Also, you can use Email templates improved by Docentric to design Alert and Workflow notifications, using the same Email body editor that supports all 3 types of embedded images.

This is how Docentric Email body editor looks.

Optional: Convert CID to Base64 encoded images

If you are using Docentric version older than 3.4.8.4 and you want to use Exchange or Graph email provider (to avoid additional mail server configuration for Office 365 SMTP Relay or because of deprecation of SMTP with Basic authentication), you can use the following extension to convert all CID images in your outgoing emails to Base64 encoded images.

This code is provided for legacy reasons and is not required in Docentric 3.4.8.4 and newer. In older Docentric versions D365FO Exchange and Graph email providers currently support only Base64 encoded images, CID images are not supported.

This is an optional extension, and you are free to use it!
Of course, there is a method in our Docentric Free Edition library DocEmailMngHelper::replaceCIDWithBase64EmbeddedImages(), so you are welcome to install it.

Download Free Edition >>

If you are not eager to do so, check the source method below 😀

See also

Email reports with images from database in the email body in D365FO >>
Troubleshooting techniques for solving emailing issues in D365FO >>
Batch email sending status improvements >>
Email or print an invoice from D365FO, depending on the customer’s email address availability >>
Emailing related articles >>
 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>