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:
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:
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.
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:
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:
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:
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!
Galanopd says
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
Paulie says
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.
Brian Bradley says
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!
Paulie says
Very possible. Good video topic! I might make that one! Where are you stuck?
Brian Bradley says
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!
Paulie says
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
Paulie says
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.
Brian says
That will be super!
Brian says
Hey Paulie, just wondering if u had a chance to do video on idea in above comments?
Paulie says
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.
Brian says
Sounds good. Will you set up meeting?
Lumiere says
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 ?
Lumiere says
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 ?
Miguel says
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
Shawna says
did the video for how to embed multiple images in a single email get uploaded? Curious on that process myself.
Scot says
Could this be done to work with the banner image url? I’m trying to automate an email notification on new news articles but have been having this display issue occur each time. Thing I’m not sure about with this method here is how to modify it so that the PicID would be able to be requested dynamically based on the banner image url image of each news post. This definitely seems like the most logical way of doing things but not sure how to get the results dynamically.
Thanks in advance
Jon says
The Base64 solution works well.
I found that thumbnail images on a SharePoint list can’t be pulled through into Power Automate (thumbnail properties don’t appear in Outputs as far as I can see), so I created a new ‘Hyperlink or Picture’ column to get this to work.
I believe I originally created the column as ‘image’ type. Images came saved from hard drive, so may be embedded in the SharePoint column.
Is there any way to use Base64 for an image column?
Not a massive problem – just recreate the column as ‘Hyperlink or Picture’, create a new Image library & upload the pictures to that.
Thanks!
Duncan says
Thanks again, Paulie. You are a true Power Automate guru. I was going crazy with others tutorials because it didn’t show my image in gmail.
Paulie says
Thanks for the great feedback Duncan
Prashant Kuruamparambatta says
Thank you so much, Paul. Your write saved my day.
Paulie says
Pleasure!