Saturday 7 August 2021

How to embed an image into an email with Power Automate

There is no OOTB feature to embed an image from the flow actions In Power Automate. This will require a bit of work to get the result. Showing up the Image on email body between MS Outlook or in web browser will be different. Due to security reasons sometimes that image/logo does not display or load properly in Outlook web because Outlook blocks that image content so, we need to manually click on the show blocked content link in the email.

Here are the steps to embed an image into the email body.

I have uploaded the image into Asset library: /SiteAssets/ImageCollection/1.jpg

1. Create the Power Automate flow with "Manually Trigger a flow" action.

2. Add SharePoint action: "Get file content using path" and select your site and provide the Image location in File Path.

3. Now the file content is retrieved with the “Get file content using path” and to embed the image content into the email body, 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.

4. Here we will using the 'Compare' action to convert the content with the below expression.

    base64(outputs('Get_file_content_using_path')?['body'])


5. Now we need to create an image HTML and add base64 converted content to that variable.

    <img src="data:image/png;base64,@{outputs('Compose')}" alt = "My Quote" />

6. Add the "HTMLImage" variable as you want to display it in the "Send an email (V2)" action email body.

booom, here is the output!

Note: Some mail clients do not support base64 encoded images. For example, Gmail does not show any base64 encoded images.

No comments:

Post a Comment