web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding an html table i...
Power Automate
Answered

Adding an html table into the body of an email

(0) ShareShare
ReportReport
Posted on by 1,176

Hi,

I'm trying to hard code an html table into the body of an email with answers provide by either an MS Form or SharePoint list
There are spaces so the field names do not appear at the top and it seems like a stepping sequence as the filed names go along. How do I get it so there are no spaces 
 
This is a snippet of my html code

ClarkyPA365_0-1699618058194.png

 


This is how the table looks within the received email

ClarkyPA365_1-1699618117331.png

 

Categories:
  • Anchov Profile Picture
    1,986 on at

    Two tips on creating HTML tables:

    1. Utilize the built-in action that allows you to create dynamic HTML tables from an array of data (Create HTML Table). For instance, you can use the output of a "Get Item" action from SharePoint. This makes the process of building tables much more straightforward and easy. This may not be applicable in your specific use case, but keep in mind for future uses.

    Anchov_0-1699624018124.png

     

    2. Apply CSS styling to your tables to customize their appearance. If you're not familiar with CSS, you can use Co-Pilot or ChatGPT to help generate a base CSS style for your tables. Here's an example to get you started:

     

    <style>
    Table {
     font-family: Arial, Helvetica, sans-serif;
     background-color: #EEEEEE;
     border-collapse: collapse;
     width: 100%;
    }
    Table td, Table th {
     border: 1px solid #ddd;
     padding: 3px 3px;
    }
    Table th {
     font-size: 15px;
     font-weight: bold;
     padding-top: 12px;
     padding-bottom: 12px;
     text-align: left;
     background-color: #1C6EA4;
     color: white;
    }
    </style>

     

    You apply the style at the top of you email HTML like this:

    Anchov_1-1699624310021.png

    Final example Email with CSS styling:

    Anchov_2-1699624379224.png


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    Cheers!
    Rick Hurt

     

  • Chris1968 Profile Picture
    1,176 on at

    Hi @Anchov 

    Thank you for prompt reply.

    The data I'm using is coming direct from MS Form responses as my snippet showed.
    I've tried to use the Append to array variable but it won't let me add a name??

    ClarkyPA365_0-1699629901274.png

     


    I believe the creator of the MS Form as linked it an Excel sheet so would this be a better option as a data source??

     

  • Anchov Profile Picture
    1,986 on at

    you will need to Initialize the array variable in the beginning, then it will be available in the drop down.

    Anchov_0-1699630188885.png

    Either the excel data source (if your are compiling a summary of responses) or the MS form (if you are showing a singular response should work.

  • Chris1968 Profile Picture
    1,176 on at

    Hi @Anchov 

    Thank you

    Added the initialize action but getting an error when I run the flow

    ClarkyPA365_0-1699630888494.png

     

    ClarkyPA365_1-1699630938145.png

     

  • Verified answer
    Anchov Profile Picture
    1,986 on at

    @ClarkyPA365,

    The error is occurring because you are passing the ID of the response to the 'Apply to each' action. The 'Apply to each' action is expecting an data-type of an array. However, in this case, since you are receiving a singular response from 'Get response details', you don't need the 'Apply to each' loop.  Here is a revised example:

    Anchov_0-1699632782158.png

    Anchov_1-1699632807359.png

     

  • Chris1968 Profile Picture
    1,176 on at

    Hi @Anchov 

    Sorry one quick question.

    I have a number of potentially a number of heading to my table.  How will I put so it shows like my table 

    ClarkyPA365_0-1700069012708.png


    Currently it looks like this.

    ClarkyPA365_1-1700069051111.png
    If I have more than 9 heading as I have above will the columns just spread across the screen??

    ClarkyPA365_2-1700069090896.png

    Not sure about the surprise of my flow showing as Co-pilot  format when editing.  Need to get use to that.
    Also other flows that I have shared with don't display in Co-pilot when editing.   

     

  • Anchov Profile Picture
    1,986 on at

    Unfortunately, with the "Create HTML Table" action, it can only generate a simple table with headings on top and data rows below in a tabular format. To address your scenario, there are a couple of options that I can think of:

    1. Create Multiple Tables: You can create multiple tables with different data and then "stack them" in your email. Each table would represent a different set of information.

      Anchov_1-1700069964726.png

       

    2. Custom HTML: Instead of relying on the "Create HTML Table" action, you can use the "Compose" action to manually construct the HTML for your email. This gives you more flexibility in designing the structure of your email.  This is essentially what you initially had, but you can enhance the appearance using CSS styling to make it more visually appealing. Utilizing ChatGPT (or co-pilot) can expedite the table generation process and assist with styling.

    I would not recommend constructing your HTML directly in the Body of the Email action. The email action attempts to correct your HTML during the save process, and often, it interferes with the formatting. To address this issue, I suggest constructing the email content in a Compose action and then referencing the Compose output in the body of the email. This approach helps to maintain the desired formatting without interference from the email action.

  • Chris1968 Profile Picture
    1,176 on at

    Hi @Anchov 

    Thank for the two possible solutions.

    I've had ago at 'Stacking' the row and ended up with this

    ClarkyPA365_0-1700142937676.png
    and the flow structure is 

     

    ClarkyPA365_1-1700142977132.png


    If I want to try option 2, Custom HTML would I need to keep how / where would I put the html code so there are breaks (<br></br> as I would also need to make some rows long than other using the colspan option.
    Also format date and times

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 271

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard