3 Things to Know About Processing Email in Power Automate

My last post explained code (JSON, HTML, CSS) in Power Automate. Now that you understand HTML and CSS, we are ready to talk about processing email in Power Automate. This post covers 3 things you need to plan for when parsing email. Read on to learn more.

The Things to Know

Power Automate has also the tools and actions necessary to process and parse email if you know what you need to plan for. There are a few things that can catch you off guard and flows fail eventually when they encounter the unexpected. So, let’s look at how to manage these situations in Power Automate.

  1. Email comes across with all of the HTML and CSS code.
  2. You must remove HTML and CSS as the first step to processing email.
  3. Power Automate interprets images in email as attachments.

No 1 – Formatting & Code

To begin, make sure that you have an email trigger setup in a flow. I am using the Office 365 Outlook trigger called When a new email arrives (V3). There are two ways to see what Power Automate gets from email. You can run the flow and click on Click to download, which opens a browser window showing you the JSON, HTML, and CSS being sent to Power Automate. I prefer a different way.

When processing email in Power Automate, I like to add a Content Conversion action called HTML to Text (preview) to see what comes out of the email. And, this step is necessary. Run the flow, and in the Inputs section, you can see exactly what comes thru from the email. If you can’t see it all, highlight the content in the INPUTS section and paste it into NotePad. Notice that you don’t just get the content of the email. You also get all of the HTML and CSS code.

And just to be clear, I sent this email. This email generated all the code shown in the second screenshot below.

<p><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style>
<!--
@font-face
	{font-family:"Cambria Math"}
@font-face
	{font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif}
span.EmailStyle17
	{font-family:"Calibri",sans-serif;
	color:windowtext}
.MsoChpDefault
	{font-family:"Calibri",sans-serif}
@page WordSection1
	{margin:1.0in 1.0in 1.0in 1.0in}
div.WordSection1
	{}
-->
</style></head><body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word"><div class="WordSection1"><p class="MsoNormal">Update forecast for 2025</p></div></body></html></p>

No 2 – Remove HTML & CSS to Process Email

We don’t need the HTML and CSS code. We get rid of it with the Content Conversion action Html to Text (preview). Configure the action with the Body of the email.

Now, you can see that code and text come in. But, only text from the email goes out. Now you have something you can work with.

Before we move on to number 3, I want to show you one more example of something you might need to prepare for. The screenshot below is an email I received from Microsoft. Because cybercrime is so pervasive, my company puts a banner on any email sent from an external email address.

If I run it thru the HTML to Text action and copy and paste the INPUT into NotePad, this is what comes thru. The banner didn’t really look like it was part of the message, but it is. If I copy and paste the INPUTS section into Word, I get six pages of HTML and CSS code. SIX PAGES! The bottom line is everything you see on the screen or in the email will come thru Power Automate as email content.

I also ran into a situation where I didn’t expect the banner to be present, but it was. I had to modify my flow to look for the banner and then process different depending on whether it found the banner.

No 3 – Images in Email Are Interpreted As Attachments

Saving attachments from email to a shared drive, SharePoint or OneDrive is a very common Power Automate use case. But, you need to know Power Automate considers images in the email body attachments. Why is this a problem? Well, people copy and paste pictures into email for a variety of reasons. For example, I have the following image in my email signature. It’s a png file.

So, knowing that I have this png in my signature, I wrote a flow to monitor my inbox for emails with the subject “FORWARD”, convert the HTML to text, and then look for an attachment. If the attachment is a PNG (my signature), it will do nothing. Any other file type gets saved in SharePoint.

To test it, I sent this email with a CSV attachment.

Power Automate processed the CSV attachement. Attachment Name does not contain png evaluated as true, so it created a file in SharePoint.

Next, it processed the signature image. Attachment Name does not contain png evaluated as false, so thing else happened.

This is a decent flow, but my logic isn’t thorough. What about other file types that might occur like jpegs or literally anything else? Well, these are things you have to take into consideration when building flows that look at email. I’ve shown you 3 things to consider when processing email in Power Automate, but I am sure there are many others.

If you enjoyed this, check out the other posts in the Learning Power Automate series.

Other Posts in the Learning Power Automate Series

Tags:

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.