• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Get in Touch
  • About Me

How to embed an image into an email with Power Automate

February 17, 2021 by Paulie 15 Comments

This post explains how to embed images inside an email sent from a Power Automate flow. This is a common requirement and can cause frustration depending on the requirements.

Generally, people want to include images stored within SharePoint, and this will be the basis of this blog post.

There are a few different methods, and I will explain the differences as we go through the post. If you prefer, here is a video explanation:

The file I am going to use for my test is in a SharePoint document library, it is called powerAutomateTestImage.png:

Image used in Power Automate Flow to test embedding an image

The full link to the file is:

https://accendo1.sharepoint.com/sites/PowerAutomateText/Images1/powerAutomateTestImage.png

Provide a simple link to the file in your email

This scenario is simple. On a client that is signed in to Office 365, you can specify the URL of the image in SharePoint and it should show in the email client:

Power Automate Flow showing the most basic method to embed an image into an emal

This works well in the Outlook Web client, but not in other clients as the file is not reachable. So unless all of your clients are using Outlook on the Web, I do not recommend this method.

Embed the image content directly into the email with Base64

This method is much more reliable as the actual content from the image is sent within the email. So there is no need for the receiver to retrieve the image from SharePoint.

Image showing Power Automate Flow that embeds an image into an email using base64

The file content is retrieved with the “Get file content using path” step. Then injected into the email as base64, with these expressions:

outputs('Get_file_content_using_path')?['body']['$content-type']
outputs('Get_file_content_using_path')?['body']['$content']

The complete image expression would be:

<img src="data:@{outputs('Get_file_content_using_path')?['body']['$content-type']};base64,@{outputs('Get_file_content_using_path')?['body']['$content']}" />

This method works really well, however some mail clients do not support base64 encoded images within the email body. For example, gmail does not show any base64 encoded images.

Another disadvantage of using this method is that the if the image is large, the email will large also. So be mindful of the size of the image that you are sending.

Use Power Automate as a HTTP Web Server

The most compatible way of embedding images in an email is to a publicly available image on the internet.

Uploading the image to a web server or CDN is best. But if you really want to use SharePoint as your source, it can be done. Its quite easily achieved by creating a flow which will serve image content via HTTP.

See this very simple flow:

Image of a Power Automate Flow that serves email images via HTTPs

This flow responds to a HTTP request with a reference to the Image in the URL. The picID in the URL refers to the ID of the image in the SharePoint document library:

Image of SharePoint document library used to store images.

The link to my HTTP Server Flow is:

https://prod-48.westeurope.logic.azure.com/workflows/59c5a92ccebe4f97adfd52eb6cf213a8/triggers/manual/paths/invoke/picID/{picID}?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=DNrMaouJY_Sifq8DRvbeWcuDl8TGKgeFpvP9NxDmOcQ

By modifying the {picID} to the ID of the image you want to serve, your private SharePoint Image will be accessible to the public. The test image used in this flow is ID 24, so this is the link to the dynamically served image. By changing the ID in the URL, a different image would be served to the client.

So now, getting back to our original email flow, we can modify it like so:

Image of Power Automate flow linking to to a Power Automate HTTP action to download embedded email images.

Now I can send the email to almost any client and it will be able to display the image. There are a couple of downsides to this method:

  • It requires a Premium Power Automate license to use the “When a HTTP Request is received” action.
  • The flow will execute every time someone looks at the email. If you are sending the email to many recipients, it will use a lot of flow capacity.

You could modify this flow to track if emails have been read, by embedding the recipient address in the URL. When the email is served to the client, you know the email has been read.

So what method should you use?

The method you should use to embed an image mostly depends on the capabilities of the recipient:

  • Don’t use the first method, unless every one of your recipients is using Outlook Web Access.
  • The base64 embedding method works well for the majority of clients.
  • The HTTP method works well for all clients. But is more work to implement and not suitable if you are sending to many recipients at once.
  • For transaction emails, I recommend using Sendgrid with Power Automate instead, it is much easier and produces a beautiful result.

Let me know in the comments how you get on and what method you choose!


Filed Under: Power Platform Tagged With: Power Automate

Reader Interactions

Comments

  1. Galanopd says

    June 21, 2021 at 2:04 pm

    Hi, very detailed and helpful but what if it is not an image within Sharepoint and it is an image on Onedrive(Personal) or an image from an external link to my website?

    Inserting doesn’t work in Send Email (V3).

    Any ideas?

    Thanks

  2. Paulie says

    June 21, 2021 at 2:06 pm

    If it is an image in OneDrive, it would be simple to modify the flow to fetch the image from there instead. If it is on an external website, it is already publicly accessible, so you should be able to link directly to it in the IMG tag.

    Send Email(V3) works in a completely different way, and actually uses SendGrid at the back end to send the message. I have no tried it but might be possible to make it work.

  3. Brian Bradley says

    July 16, 2021 at 1:13 am

    Paul, Is it possible to create a flow in Power Automate to loop through e.g. the last week of images in an image library and send all of those PICs in Email?
    Another scenario is that I’m using using Get Items from SharePoint and trying to get the Author.Picture from a SharePoint calendar. I’m trying to include the Picture in a Select table and then send in Email. Is that possible?
    Thanks for your videos. They’ve been really helpful!

  4. Paulie says

    July 16, 2021 at 6:53 am

    Very possible. Good video topic! I might make that one! Where are you stuck?

  5. Brian Bradley says

    July 16, 2021 at 7:12 pm

    Hey Paulie, So I get the Items in from SharePoint. But I’m not seeing a way to get the Get File Content by Path dynamically($Content). I tried putting it in a forEach loop, but it kept timing out. I was wanting to put the Author.Picture in a table as a nice addition, but this only seems to work for static images? I asked the same question in the forum, but no replies.

    https://powerusers.microsoft.com/t5/Building-Flows/Embed-Image-from-SharePoint-into-Table-Dynamically/m-p/1189103#M137717

    Also it would be great to be able to loop through a Picture Library and e.g. get the last weeks of pictures and send them in an email. Thx!

  6. Paulie says

    July 16, 2021 at 10:19 pm

    Hi Brian, I can produce a flow that does what you want. But I am on holiday at the moment without good internet access. Will have a look in a few days

  7. Paulie says

    July 17, 2021 at 8:37 am

    Hi Brian,

    I had a quick play with it and have done what you want – will record a video for you when I am back.

  8. Brian says

    July 17, 2021 at 7:52 pm

    That will be super!

  9. Brian says

    August 4, 2021 at 4:54 pm

    Hey Paulie, just wondering if u had a chance to do video on idea in above comments?

  10. Paulie says

    August 4, 2021 at 5:41 pm

    I didn’t get round to it, fancy doing it together on a live stream and then publishing to YouTube? We can use my Office 365 environment or yours. You can explain what you need and I can build it out.

  11. Brian says

    August 4, 2021 at 9:55 pm

    Sounds good. Will you set up meeting?

  12. Lumiere says

    October 15, 2021 at 7:33 am

    Hello My champion,

    Hope you are doing well.

    I need you advise please:

    There is huge number of documents placed in sharepoint that are pending for approval and my signature is required

    Iam trying to make a power app in which i can select multiple pdf documents and insert/embed to it my signature as an “image” and I don’t want to use the pen

    Please please help

    Thanks with love ?

  13. Lumiere says

    October 15, 2021 at 7:35 am

    Hello My champion,

    Hope you are doing well.

    I need you advise please:

    There is huge number of documents placed in sharepoint that are pending for approval and my signature is required

    Iam trying to make a power app in which i can select multiple pdf documents and insert/embed to it my signature as an “image” and I don’t want to use the pen

    Please please help

    Thanks with love ?

  14. Miguel says

    March 18, 2022 at 6:32 pm

    Paul, hi!
    Thanks for this post. It’s helped me understand Power Automate a little better (still a lot to learn!). I managed to make the image (my logo in the email signature) in base64 appear in the emails. But.. I want to make it also work for gmail and other clients.

    It seems I’m missing something in your explanation for serving the image from Sharepoint.

    How do you get to the first step? I create a NEW (Instant cloud) flow with a “When HTTP Request is Received” trigger. I don’t get what I have to add to the HTTP POST URL or how. I tried adding the URL I got from the Image in SharePoint, but nothing happens.

    The HTTP POST URL just says “URL will be generated after save”, doesn’t allow me to insert anything and the Save button is inactive.

    Thanks for your help with this!
    Miguel

  15. Shawna says

    May 4, 2022 at 6:44 pm

    did the video for how to embed multiple images in a single email get uploaded? Curious on that process myself.

Leave a Reply Cancel reply

Primary Sidebar

Link to my LinkedIn Profile
Buy me a coffee
Image link to all Power Automate content

Excellent Power Automate Blogs

  • Damien Bird
  • Dennis (Expiscornovus)
  • Tom Riha

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 259 other subscribers.

Go to mobile version