Embed Logo/Image As Content In An Email In PowerAutomate (MS Flow)

Introduction

  • When we send an email from Power Automate (MS Flow) and if we have a need to add a company logo or embed an image with that email. 
  • To send an image or logo with an email generally, In <img src...> we add a link to the image from the Site Assets library,
  • Due to security reasons sometimes that image/logo does not display or load properly in Outlook web or Outlook client because Outlook blocks that image content so, we need to manually click on the show blocked content link in the email.
  • To resolve this problem I have a solution. So, let's get started.

How we can achieve this?

To send an image with the email body follow the below steps:

  • First, we will upload an image/logo to the Site Assets library.

  • Next, create a flow. Here, I am creating an automated cloud flow and the trigger is When an item is created or modified.

Embed logo/image as content in an email in PowerAutomate

  • Give the appropriate flow name and click on Create button.

Embed logo/image as content in an email in PowerAutomate

  • Now, select the site address and list name.
  • Next, add an action "Get file content". Select the site address where we have put the site logo or an image that we want to send with an email. Select, the path of that image/logo in File Identifier. (Get file content will convert an image into the content and that content we can pass with the email).

Embed logo/image as content in an email in PowerAutomate

  •  Next, we have got the content of that image and before we send that content with an email, we need to convert that content into base64 (Base64 is an encoding algorithm that converts any characters, binary data, and even images or sound files into a readable string, which can be saved or transported over the network without data loss).
  • So, here to convert the image content we will use the Compose action to convert.
  • Use the below formula as an expression in the Compose action.

    base64(outputs('Get_file_content')?['body'])
     
  • Next, initialize a String type variable so, we can create an image HTML and add base64 converted content to that variable.
  • Paste the below code to create the HTML of the image.

    <img src="data:image/png;base64,@{outputs('Compose')}" width="200" height="86">

Embed logo/image as content in an email in PowerAutomate

  • Next, we will add the "Send an email (V2)" action to send an email to the user. 
  • Add the "ImageHTML" variable as you want to display it in the email body.
  • Here, I have converted a logo and ImageHTML has the logo value. So, I am adding ImageHTML at the top of the email body.

Embed logo/image as content in an email in PowerAutomate

  • So here we have completed the flow development. You can test the flow and you'll get the logo/image in the email.
  • Here, I have a test result as below:

Done!