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

14 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Kate
Kate
2 months 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
2 months 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
2 months ago

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

My S
My S
2 months ago

Hi Matthew, very nice, one question, how to scale image in email width should be 100%.

Thank you

Manish Solanki
2 months 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!

Borja
Borja
1 month ago

Hi, thanks for the tutorial!

Tried method #1 for Gmail but doesn´t work for me, Gmail just deletes all kind of img element. Any idea why and how to avoid it?

¿Is it possible to send embebbed images from PowerApps ( Sen Email V2 function) to Gmail using Outlook connector?

Thanks a lot

Elijah
Elijah
1 month ago

Didn’t work for me

IMG_7450.png
Joel Zehring
1 month ago

Thanks for this, Matthew!

Maybe worth noting… I had to escape the ‘@’ character in order to clear an error when trying to save my flow. The format that worked for me:

“@@odata.type”: “#microsoft.graph.fileAttachment”

It seems like Power Automate might be stripping this escape character after I exit then re-enter the flow designer, but that’s just a hunch.

Also, my test emails so far display a broken image icon where my image should be… I’ve tried jpg and png, and double-checked I’m getting the correct properties from the SharePoint Get file content action. Is there a chance the Azure app registration needs to be configured differently?

Venkat
1 month ago

can do with pptx file?