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

Tachytelic.net

  • Sco Openserver
    • Sco Unix Support
    • SCO Openserver Installation ISOs
    • SCO Openserver Binaries
    • Add a Hard Drive to an Openserver 5 Virtual Machine
    • Install SCO Vision SQL-Retriever ODBC Driver on Windows 10
    • License Expired on Virtual SCO Openserver Installation
    • How to reset the root password on SCO Openserver 5
  • Scripting
    • PowerShell
      • Add leading zeros
      • Check if a File Exists
      • Grep with Powershell
      • Create Environment Variables
      • Test for open Ports
      • Append to a Text File
    • VBScript
      • Check if a File Exists
      • lpad and rpad functions
      • Windows Update E-Mail Notification
  • Office 365
    • Connect to Office 365 with PowerShell
    • Add or remove an email alias using Powershell
    • Change Primary email address of Active Directory user
    • How to hide an AD user from the Global Address List
    • How to hide mail contacts from the Global Address List
    • Change the primary email address for an account with PowerShell
    • Change Primary email address of an AD User
    • Grant a single user access to access to all calendars
    • Forward email to an external address using Powershell
    • Convert shared mailbox to user mailbox with Powershell
  • Get in Touch
  • About Me
    • Privacy Policy

How to embed an image into an email with Power Automate

February 17, 2021 by Paulie Leave a Comment

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

Leave a Reply Cancel reply

Primary Sidebar

Power Automate Support Image
Link to my LinkedIn Profile

Subscribe to Blog via Email

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

Join 107 other subscribers.

Go to mobile version