top of page
Writer's pictureJon Russell

Format an HTML Table with CSS and add links in Power Automate


Format HTML Table with CSS and add links main image

Contents


Hey everyone, how are you doing?


This is quite a common use case for me, and it really helps the look and feel when you want to send an email with a list of items to someone via email, having the ability to format an HTML table with CSS and add links.


The Use Case


I have been busy building a Model-driven app and some Power Automate cloud flows to help automate parts of our Sprint 0 Podcast, that myself and my friend Mike Gowland have started together. For part of this, I wanted to send Mike and myself an email with a list of Podcast guests that we would need to record, where the recordings were taking place in the next 7 days.


Steps for the Power Automate cloud flow


The flow starts with a recurring trigger, then the next step is to initialize an array variable, which I have called HTMLTable:


Step 1 create array

I then do a list rows, this is using a filter XML condition to get back some specific rows, i.e. the podcast recordings that are happening in the next 7 days:


Step 2 list rows

Next, I have a compose step, this holds the CSS needed for the formatting:


Create CSS Style

The code for the CSS is below:


<style>
table {
  border: 1px solid #1C6EA4;
  background-color: #EEEEEE;
  width: 100%;
  text-align: left;
  border-collapse: collapse;
}
table td, table th {
  border: 1px solid #AAAAAA;
  padding: 3px 2px;
}
table tbody td {
  font-size: 13px;
}
table thead {
  background: #1C6EA4;
  border-bottom: 2px solid #444444;
}
table thead th {
  font-size: 15px;
  font-weight: bold;
  color: #FFFFFF;
  border-left: 2px solid #D0E4F5;
}
table thead th:first-child {
  border-left: none;
}
</style>

We then add an Apply to each step and choose the value from the List rows steps above to iterate through. I then have another compose step where I compose the URL I need to add as a hyperlink in the HTMLTable that will be used in conjunction with the CSS Style output.


The Power Fx for the Clickable URL is:


Here I am building up a string as a hyperlink.


Next I add an Append to array variable step, and update the HTMLTable array variable I created earlier, choosing the fields that I need from the List rows step, as well as the outputs from the Compose Clickable URL step:


Step 3 apply to each

Next I add a Create HTML table action, and choose the HTMLTable array variable from the dynamic content:


Step 4 Create HTML Table

Finally, I create a Send an email step, and choose the outputs followed by an expression to cater for the special characters that get added from the Create HTML table step, the replace expression is below:


Step 5 send an email

replace(replace(replace(body('Create_HTML_table'),'&lt;','<'),'&gt;','>'),'&quot;','"')

Here we are replacing the encoded characters with the characters we need to create the hyperlink.


The Result


When the cloud flow runs, we get a nicely formatted table in the email, with clickable links, direct to the record in the Model Driven App:


Step 6 The Result


As always, thanks for reading, I hope you are well, and if you have any questions you know where I am:


3,113 views1 comment

Recent Posts

See All

1 Comment


 Automating the process with Power Automate to send email lists with HTML tables and CSS is a smart move. If you're juggling this along with academic tasks, you can buy assignment help from us to manage your workload and stay focused on what matters most.

Like
bottom of page