It’s simple when you know how!
Task:
Using Microsoft Flow, trigger the sending of an email with an embedded image.
- The image will be stored in a SharePoint Library
- We will assume you have already created connections to:
- Office 365 Outlook
- SharePoint
Steps:
- Create a new Flow:
- Select: +New > Instant—from blank
- Click: Manually trigger a flow
- Add the 1st actions:
- Search for SharePoint > Get file content using the path
- Select the action
- Site Address: either select or ‘enter custom value’
- File Path: enter the path from the site collection (e.g. ‘/Style%20Library/_Company/Images/EmailSignature.jpg’)
- Add the 2nd actions:
- Search for Variables > Initialize variable
- Select the action
- Name: Enter ImageTag
- Type: Select String
- Value: This is the trick bit!*
- Enter: <img src=”data:image/jpeg;base64,” alt=”My Image” />
- Next click between ‘64,‘ and ‘” alt‘
- Add dynamic content
- Select: Expression fx
- Enter .$content
- Placing your cursor before the .$content click: Dynamic content
- Locate and select File Content
- Click OK
- Add the 3rd and last actions:
- Search for Office 365 Outlook > Send an email
- Select the action
- To: enter your email address
- Subject: Microsoft Flow: How to embed an image in an email
- Body: <p>This is my test email, you should see an image below</p><p></p>
- Click between the last <p></p> tags
- Click: Add dynamic content
- Locate and select the ImageTag variable
- Is HTML: Select Yes
- Save the Flow
*Here is the full code/expression:
<img src="data:image/jpeg;base64,@{body('Get_file_content_using_path')['$content']}" alt="My Image" />
So what tripped me up?
On my first attempt I tied using the File Content variable directly within the body of the email, only to see binary… Note: This works fine when attaching the file as an ‘attachment’ (see Attachments Content).
Plus I struggled to find a way to convert binary to base64. That was before I realised I didn’t need to do all that work, hence this blog post…
You must be logged in to post a comment.