3 Ways Power Automate Can Embed An Image In Email

3 Ways Power Automate Can Embed An Image In Email

Want Power Automate to embed an image in email? I’ve done the research and I will show you the best ways to do it. Displaying an image properly in all email client is not an easy task. My goal was to find the most compatible and the cleanest method possible while still using standard licensing. And if you have a premium license I’ve got a neat trick to share with you that uses the Microsoft Graph API.

Table of Contents
• Introduction: The Email With An Image AutomationSetup The SharePoint Document LibraryMethod #1: Embed Image In Email Using Content IDMethod #2: Embed Image In Email Using Data URIMethod #3: Embed Image In Email Using Hidden Content ID

We will use Power Automate to send an email with an embedded image. The image appears in the body of the email instead of as an attachment.




Setup The SharePoint Document Library

The examples in this article use an image stored in a SharePoint document library. Create a new document library named Email Embed Images and add an image to it.



To follow along with the examples use this image named Business-Cat.jpg.




Method #1: Embed Image In Email Using Content ID

The most reliable way to embed an image in an email with a standard license is using Content-IDs (CID). It is supported by all versions of Outlook and even works in Gmail.

✅ Desktop Outlook
✅ Desktop Outlook (New)
✅ iOS Outlook
✅ Outlook Web
✅ Gmail



This Power Automate flow gets the image file content from SharePoint and then adds as an attachment to the email. Then the email displays the image in the body of the email by making a reference to it in an IMG tag. The image path (src) is prefixed CID: and matches the attachment name.



Use this code in the Data Operations – Compose action.

<img src='cid:Business-Cat.jpg' />



Test the flow by sending an email. The email appears with an image displaying in the body.



The only drawback of this the Content ID method is it displays an attachment icon. This is misleading to the email recipient because there are no downloadable attachments in the email.




Method #2: Embed Image In Email Using Data URI

Embedding the image as Base64 is the cleanest method because there is no attachment image beside the email. However, not all email clients have support for Base64. Only use it if you have a standard license and you know the recipient will use a compatible email client.

✅ Desktop Outlook
✅ Desktop Outlook (New)
✅ iOS Outlook
❌ Outlook Web
❌ Gmail



The Power Automate flow gets the image content from SharePoint and converts it to Base64 using the dataURI function. The Base64 is placed inside of an IMG tag and displayed in the body of the email.



Use this code in the Data Operations – Compose action.

<img src='@{dataUri(body('Get_file_content_using_path:_Embed_Image'))}' />



Run the flow to send an email. The result looks like this:



No attachment icon is shown when embedding images as Base64.




Method #3: Embed Image In Email Using Hidden Content ID

A premium-licensed flow is the best method because it can send embedded images that are fully compatible with all email clients and hide the attachment icon. It achieves this by using both Content IDs and inline email attachments.

✅ Desktop Outlook
✅ Desktop Outlook (New)
✅ iOS Outlook
✅ Outlook Web
✅ Gmail



This flow is the same as Method #1 except it replaces the Send Email action with an HTTP with Microsoft Entra ID (preauthorized) – Invoke An HTTP Request action. Then it creates and sends the email using the Microsoft Graph API. The reason we use the Graph API is it gives us the ability to set an attachment as inline.



When creating the connection to Microsoft Entra ID use https://graph.microsoft.com as the Base Resource URL and Azure AD Resource.



Write this code in the Data Operations – Compose action.

<img src='cid:Business-Cat.jpg' />



Choose the POST method and use this URI for the Invoke an HTTP Request action.

https://graph.microsoft.com/v1.0/me/sendMail



Use this key-value pairing in the request headers.

KeyValue
Content-typeapplication/json



Copy and paste this code into the body of the request. The isInline property of the attachment makes it hidden.

{
  "message": {
    "subject": "Email With Embedded Image (Hidden Content ID Method)",
    "body": {
      "contentType": "HTML",
      "content": "@{outputs('Compose:_Image_Tag_With_Content_ID')}"
    },
    "toRecipients": [
      {
        "emailAddress": {
          "address": "[email protected]"
        }
      }
    ],
    "attachments": [
      {
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "Business-Cat.jpg",
        "contentType": "@{body('Get_file_content_using_path:_Embed_Image')?['$content-type']}",
        "contentBytes": "@{body('Get_file_content_using_path:_Embed_Image')?['$content']}",
        "isInline": true
      }
    ]
  }
}



Test the flow. The email arrives in the recipients inbox and shows an embedded image in the body.



There is no attachment icon showing for the email.





Questions?

If you have any questions or feedback about 3 Ways Power Automate Can Embed An Image In Email please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

10 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Kate
Kate
1 month ago

thank you for this tutorial. It would be great if you could explain more in detail the used function … for citizen dev, it would be helpful to explain how you build the code sentence. have a nice weekend

Mikaël
Mikaël
1 month ago

An excellent piece of work which explains the various possibilities very well’.

The third method also works with ‘sent en email V2’ if you include the contentBytes in the HTML code of the email. Why it is necessary to use graph?

Craig White
Craig White
1 month ago

Great article, thanks Matthew. It’s always been a pain to get images working for Google Mail recipients so this is gold dust.

Manish Solanki
1 month ago

Thank you for sharing this. Few days back, I had suggested using datauri approach on power automate community for embedding gif image:
Solved: Re: Add GIF image into the email body – Power Platform Community (microsoft.com)

But I have observed that when size of the image becomes more approximately > 1 MB then image does not show in outlook web client. But when I follow this blog and use method# 3 (Embed Image in Email Using Hidden Content ID), I am able to embed that image in the email body.
Thank you!

Venkat
20 days ago

can do with pptx file?