Two years ago, I wrote a similar post on Microsoft Flow: How to pass the SQL data table results in a Markdown-formatted table into an Email notification or Approval Requests. It is still quite up to date, i.e., it is an excellent solution that you can still use today. The only problem with that article is that I was using “send an email” action in Power Automate Outlook connector that is currently deprecated.
This action was great in my perspective because we were able to directly put HTML code on the body property and define that the email body format would be HTML by setting the property Is HTML to true.
Deprecated Power Automate Outlook connector
Quite simple to use and efficient.
However, Send an email (V2) action has totally different behaviour. First of all, it owns fewer properties:
- Is HTML property was removed from this action
And a completely new look and feel of the Body property as you see in the picture below:
- With a powerful editor similar to what we have in our office tools (Word, Outlook, …)
But that also means that we no longer have the possibility to directly insert HTML code into the body property of the message, as we did earlier with the previous version. Well, we can write HTML code on the body of this action:
But the end result will not be what you expect:
Luckily for us, on the Power Automate designer, we will see a Code View button (</>)
If you click it, you will see that everything that we will put directly on the body editor will be considered as text:
So, if we want to send a well-formatted custom HTML email we have two options:
- Using the View Code feature on the Body Editor
- Using a support Variable
On the Send an Email (V2) Body editor, switch to View Code and place the custom HTML code inside: Doing that, you will notice that the editor will be blocked on the view code viewer. If you test it now, you will see that you will be receiving a well-formatted HTML email in your mailbox: This approach is good if you just want to send a static email or with a pre-defined structure, not subject to changes in runtime. With this approach, you need to create a Variable and put the entire code inside that variable: Then define directly on the Body editor (without switching to Code View) that the body will be the content of the Variable we created: You will see that you will also be receiving a well-formatted HTML email on your mailbox: This approach will be better for dynamic body structures that you need to build based on some inputs of external systems. Hope this helps!Option 2: Using a support Variable
Related reading