How-To #5: Format Links Sent via Email in Power Automate

In this post, I will show you how to format links in the Create HTML table and Send an email actions in Power Automate.

When adding an link to one of the columns in the Create HTML table action, the link is expected to only show the respective title of the link with an underline, like this Link. Instead, you get something like the link displayed below. Yeah, nobody wants to see that.

<a href="">Link<a/>

For this example, I will use data from a SharePoint – Get items action since the Create HTML table action requires data from an array. Please follow the steps below:

  1. In the Create HTML table action, set the * From field to the value of the Get items action from the dynamic content window, and change the * Columns value from Automatic to Custom.
  2. Add a name for each of the header you will use along with its value. Once you get to the header that will display the link, set its value to the following expression:
concat('<a href="', item()['{Link}'], '">Link</a>')

This expression uses the concat() function to concatenate the following strings and craft the link that will be included in the body of the email:
String 1: <a href=”
String 2: item()[‘{Link}’] (This is dynamic content from the Get items action)
String 3: “>Link

  1. In the Send an email (V2) action, we will use the Output of the Create HTML table, but rather than adding it straight up into the body of the email, we need to wrap it inside an expression using 3 replace() functions. I know you are wondering why we need to this. That’s a valid question and I will answer it below. This is what the expressions looks like:
replace(replace(replace(body('Create_HTML_table'), '&lt;a href=&quot;', '<a href="'), '&quot;&gt;', '">'), '&lt;a/&gt;', '</a>')

The reason to use this expression is due to the fact that the email body encodes certain characters, i.e. < to &lt, and they need to be converted back to the original character so the email is properly formatted. Now, let’s look at the breakdown of the expression. The first thing to point out is that expressions are executed like math, from the inside out.

  • The first replace() function that will be executed is replace(body(‘Create_HTML_table’), ‘&lt;a href=&quot;’, ‘<a href=”‘). This replace() will find &lt;a href=&quot; and it will replace it with <a href=.
  • Once the previous expression is executed, the second replace() will find &quot;&gt; and it will replace it with “>.
  • And finally, once the two previous replace() expressions are executed, the third replace() will find &lt;a/&gt and it will replace it with </a>.

The image below shows what the email actually looks like. Big difference, right?

Bonus section
To view the encoding that Outlook does to the messages, follow the steps outlined below:

  1. Open the message in a separate window and click on Actions.
  2. When the menu expands, click on Other Actions and click on View Source.
    This will open a text file in Notepad, which contains all the message information formatted in HTML.

Please give this a try and let me know in the comments section below. Thank you for reading and have a wonderful day 😀

Photo by Markus Spiske on Unsplash

4 thoughts on “How-To #5: Format Links Sent via Email in Power Automate

  1. Hello, I followed the instructions above, using copy/paste for the expressions so that I entered them exactly like yours, but this is not working for me. The problems I am having are that I only want to see the item one time, not three times, and I do not want to see displayed as part of the actual link. I have copy/pasted the results below that I am seeing directly from the email. Thank you.

    ID Title LinkToItem
    23 TEST 2 Report or Extract Name_FD_4567890_A2i Link

    23 TEST 2 Report or Extract Name_FD_4567890_A2i Link

    23 TEST 2 Report or Extract Name_FD_4567890_A2i Link


    1. Hmm. Your comment box formatted my text so that my actual results are not showing in the comment I made. You can see where my item is listing itself 3 times instead of once. But the link part let me try that again . . . Here is how the link looks, except without the spaces: Link


      1. Again your comment box is reformatting my comment. 😦 Last try . . . the closing ” a ” tag is displayed in the text along side the word Link, and I don’t know how to get it to stop showing. Thanks.


Leave a Reply to tonieb Cancel reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s