Power Automate: Add a table in Email

#PowerAutomate, #Email, #Notification, #Table, #Json

Hi guys, Last week, my client approached me with a request: they wanted the system to be capable of sending email notifications to the sales manager, containing a list of new Deals daily. (It means the list of Deals has "New" status)

...and I said, "Yes, sure". -> Now, we will do that.

My propose: Using Power Automate

The details of my Power Automate:

  • Type of Power Automate: Scheduled.

  • Frequency: Daily at 00:05 am

  • The flow will filter all Deal records that have the status reason "New"

  • Then send this list to the Sales Manager. For instance, I will send it to a specific email: "dung@ntd.asia"

  • Using the Create HTML table {} action of Data Operation is to generate a table from Dataverse records.

My steps: Schedule Flow -> Get List rows (from Dataverse) -> Create HTML Table -> Send Email (V2)

First of all, I have the list of Active Deals below and I expect the system will send 2 Deals with the New Status to my email "dung@ntd.asia".

Creating Power Automate

In my solution, choose Cloud Flow > click New to create

After creating, I added new step "List rows" from "Dataverse" > select my table Deal and set Filter for this step.

My sample, I filter Deals has Status Reason = "New"' ==> statuscode eq 1

**Action: Create HTML Table {}

In the 3rd step, I added an action Create HTML Table {} in "Data Operation"

Run testing and check the Output of step "Create HTML table". Because I selected the option Automatic of Columns, so all columns of the Deal entity will be shown below.

Then I edit the option Column to Custom -> and create the custom mapping for the table

After using custom mapping, we have the result:

Add step Send Email (V2)

I added the Send Email (V2) to the final step. In this step, I used the Output of action "Create HTM table {}" and added it to the email's body.

First Testing...

After finishing the first version, I tested and saw the table has no border:

**Using Compose {} action & Final Flow

Then, I edit my Power Automate and use the action Compose {} of Data Operation. This action I used this to add a border for the table.

I used the expression Replace() to take the table and replace the reference to the table object to include a format style.

My expression:

replace(body('Create_HTML_table'),'<table>','<table border=”1″>')

And the latest version of Power Automate, in the email body, I used the Output of step "Compose".

-> Running Test and check the result: The table has a border :)

Thank you and hoping well. 🎉 [NTD]yns.asia ...invite me a cup. Thank you. ❤️

Last updated