SAP Business Technology Platform’s Integration Suite(Formerly SAP CPI) have the ability to send mails through Mail adapter. We can send the attachments along with a well formatted body of the mail. Refer blog by Ajay Vaddemani.
Many of us have the requirement to send the Image to the mail body, for which typically Base 64 encoded image can be called in HTML body as described by Sriprasad Shivaram Bhat in his answer.
However, Base 64 adapter is not well supported in many of the eMail clients. below table suggest the behavior with different email clients.
Due to these restrictions Base 64 is not an efficient way to embedd images in the mail body.
Alternatively we have 3 more ways to do this:
- Linked Images, hosted pictures called in HTML through URL– used widely, but we need to host image in an server or hosting agent.
- Background image in CSS- create background Image style in HTML and call that style in the HTML body, not efficient as it also need Base 64 image to be loaded in CSS Style.
- Embedding images using CID attachment- I found this to be an impressive way which doesn’t need any external server to host the image and base 64 as well.
We will understand the option Embedding images using CID attachment in this blog using a simple SFTP to load image and Mail adapter to send the image.
In order to achieve this we just need to pass the image in Attachment and then call the image in HTML mail body using Content-ID.
1. Use SFTP to load the image- this process varies as per your requirement, you can call the image from a Data store as well.
2. Create a Content-ID Header in Content Modifier
3. Load the image in Mail adapter as attachment
Content Modifier: create constant Header Content-ID and pass any logical value within <> as shown in the screenshot, I have used Content-ID as <image>
Now we can call the attachment through cid in the img tag of HTML (Without <>).
Following the above steps we can successfully send the image embedded in the mail body and it resolves the restriction of forwarding or Downloading/Saving the image from mail that we were facing in Base 64 technique.