Power Automate: Format HTML tables while sending them within a mail

Introduction

In this article we will see how to format HTML tables while sending them within a mail using Power Automate

We have a list called Tickets that contains the details of issues that have been logged for resolution. We will be creating a flow that will send out reminder mails about unresolved tickers in an html table as shown below.

Create Flow

Since we want to run the flow on a recurring basis to send out reports of unresolved tickets, we will be making use of the recurrence action as the trigger so that the flow runs after every predefined interval.

Here we are assigning an interval of 1 day so that it triggers the reminder mail every day.

Now we need to get the details of all the items that has the status “Resolved” as No. So as to fetch these items, we will be using the Get Items action and will use the filter condition Resolved eq 'No'

Once we have the items, lets format the items into a table . To do that , the first step is to create a key value pair of the data , which we will be doing using the Data Operations – Select option.

Once the keyvalue pairs are created, we will use it as the input for the HTML action which will convert it into easily readable HTML table.

We will then use it to send as an email body.

However as you can see in the received email, the html table does not have any borders and spacing. Lets add some formatting to the html table by adding borders

Add Border

We will add border by adding the compose action and using the expression :

replace(body('Create_HTML_table'),'<``table``>’,'<``table border``=``"1"``>')

Once we have added the border, lets add a bit of cell spacing as well using another compose action and use the expression :

replace(outputs('FormatTable'),'<``td``>','<``td style``=``"padding:20px"``>')

The entire Flow would like this

  

Test the Flow

On testing the flow, we will be getting the mails with proper formatting as shown below :

Summary

Thus we saw how we can format the HTML tables for use within mails using Power Automate