Microsoft Flow Email Body Format
I was working on my newsletter’s solution, aimed to automatically send prepared messages hosted in my SharePoint. Naturally, newsletters often contain images.
Lots of them frankly speaking. The most straightforward approach was to insert them as a URL to the physical file stored in SharePoint (described ). However, in that approach, if a recipient has no access to the site, where the file is hosted or is not yet logged in, the images won’t show up.How to embed images into the body?There are in fact three approaches:. The “src” attribute pointing to the file hosted somewhere;. The “src=cid” (Content-ID) – so the internal linking in the e-mail, if the file is physically attached to the e-mail it can be displayed inline using the “cid” ;.
Embedding image using base64 encoded string, and the “ src= data:image/jpeg;base64,” (or png, or gif) value of the src attribute.Ad. 1 – it works like a charm, but as I mentioned above – only when user really has an access to the file.Ad. 2 – Flow allows you to add only one attachment. You cannot add multiple (you can vote for it ). So the approach with showing images inline using the “ cid method” is not very possible in case you want to show more than one file.Ad.
3 – seemed to be feasible in Flow, however I was also aware, that unfortunately most of the e-mail clients do not support it. This old, but still up-to-date post shows support for base64 encoded images embedded in e-mails: The base64 approachAs I wrote above, that is fairly easy to do. I managed to do it in couple of steps (having in mind that pure regular expressions are not yet available for Flow, vote for them ):. First I processed the newsletter’s body, to extract all images paths. I’m doing it in less straightforward way.
First, I split the whole message body using the ‘src=”‘ token: split(variables('varBodyStr'), 'src='). Then, for each token (split creates an array), I am extracting substring from its beginning until the quote char, what should always return a full image path: substring(item, 0, indexOf(item, ')). Then, I am building an absolute path to the image and using action “Get file content using path” I am getting file contents which then I am transforming to the right base64 structure.
- For customize email body add below html in between body section. To save email body then click on ok. Click on email then add current item customer name, address, region and country then click ok to save entire email massage. Then End’s workflow transition after that save and publish workflow.
- This is the part of the cheatsheet series on Microsoft Flow. JSON cheatsheet for Microsoft Flow (this article) Nested-Flow / Reusable-Function cheatsheet for Microsoft Flow. Building non-JSON webservices with Flow. One Connection to Proxy Them All - Microsoft Flow with Azure Functions Proxies. Building Binary output service with Microsoft Flow.
Microsoft Flow Email Body Format Example
Let's do this. Find, and then add the Data Operations - Filter array (filter array) action to your flow. Configure the filter array action like the following image. Save, and then run your flow. You can use PostMan to generate a web request that sends a JSON array to your flow.