Introduction
We often need to send emails via Power Automate, where the data needs to be formatted as a table. In this article, we will see how to create an HTML table, beautify it using CSS, and then use it in emails sent by Power Automate.
Business Case
We have a SharePoint list to support the business related to Engineering Change Requests (ECR). Various departments use this list to initiate engineering change requests, which are then approved by key stakeholders. Every day, we need to compile the items pending approval into a table and send out an email to remind the relevant approver.Some data fields (columns) of the ECR list are shown in the figure below. Additionally, there are fields like Approver and ECR Decision that are not included in the figure.
 |
ECR List |
Flow Overview
The ECR pending approval reminder flow is shown in the figure below.
 |
Power Automate Flow Overview |
Implementation
From an implementation perspective, we will use a scheduled cloud flow. We will set this flow to run at 9:00 AM every day. We will also filter the data retrieved from the list so that only the data pending approval is brought into Power Automate for processing.
 |
Scheduled Flow Trigger |
 |
Get Items Action |
The next step is to map the column names to the table headers so that we can build an HTML table out of it. We will add a select action and map it as below.
 |
Map the Fields to Headers |
Now we will add the action to Create an HTML table and pass on the output from the select action to it.
 |
Create HTML Table |
Now we can call the action to Send an email, but the HTML table presented in the email will be quite plain and unformatted, which will render the table in the email as below without any styles.
 |
Send an Email - Unformatted HTML Table |
 |
Email - Unformatted HTML Table |
|
To beautify the table, we will add an Compose action and append CSS styles to the output of the Create HTML table action. There are multiple online websites that can help you create beautiful CSS, such as Table Styler or DivTable.
 |
Append CSS Styles to HTML Table |
Finally, we will add the Send an Email action to send out the information of the daily pending items to the relevant approver. This time we have used the formatted and styled output from the Compose action in the email body.
 |
Send an Email - Styled HTML Table
|
Testing the Flow
We can manually test the flow without having to wait for the scheduled time of the flow. The manual test retrieves the information of the pending items and sends an email with the styled table to the relevant approver.
 |
Email - Styled HTML Table
|
Conclusion
In this way, we saw how to set up a flow to fetch details at a specific time and send it as a beautifully styled HTML table via email.
0 Comments