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).
    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.
    Cons: has to be done programmatically, might be blocked in some email clients and increases the email size.

  • 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.
    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.

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 embedded CID or Base64 encoded images, you will stumble upon a new problem: D365FO Exchange email provider doesn't support CID images.

As you know, there are 2 types of non-interactive Email providers in D365FO: Exchange and SMTP. And unlike Exchange, SMTP email provider supports all 3 types of embedded images. So, one could say that SMTP email provider is the way to go in D365FO to support embedding images in outgoing emails. But wait, bad news! Recently, Microsoft announced Deprecation of Basic authentication in Exchange Online, which currently represents the only authentication option to use SMTP email provider in D365FO 😢 (i.e. to authenticate sending user on Exchange Online server with username and password). What now?!

How to overcome D365FO emailing limitations for embedded images

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.

In one of the next releases, Docentric will deliver:

  • MS OAuth 2.0 authentication for D365FO SMTP email provider. Yay!
  • Optional fix for converting CID images to Base64 encoded images for D365FO Exchange email provider, please see below.
You can also use SMTP email provider with Office 365 SMTP Relay, which doesn’t require user authentication.

Convert CID to Base64 encoded images for D365FO Exchange email provider

If you are using Docentric, then you might have been using SMTP email provider and CID images in your outgoing emails so far. If you need to switch to Exchange (to avoid additional mail server configuration or because of deprecation of Basic authentication), you can use the following extension to convert all CID images in your outgoing emails to Base64 encoded images, which are supported by D365FO Exchange email provider as well.

D365FO Exchange email provider currently supports 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 >>