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 / email body with html t...
Power Automate
Answered

email body with html text and body to sharepoint excel table

(0) ShareShare
ReportReport
Posted on by 4

Hi everyone,

 

I've had some success building the flow to add to excel table on sharepoint but the problem is the format in which i get the email in.

 

Bolded below.....

 

Hi,

The following items and values are here:

 

Column1Column2Column3Column4Column5Column6Column7
Value1Value2Value3Value4Value5Value6Value7

The problem is that I only want the html table, not the text and the values which change.

When I convert from html to text the format is hard to clean up in power query.

 

Thanks!

 

Categories:
I have the same question (0)
  • eliotcole Profile Picture
    4,390 Moderator on at

    The following expression will extract the first table in that email's HTML body.

     

    For the purposes of this, I have placed the email HTML body variable called "emailBodyVAR".

     

    concat('<table', first(split(first(skip(split(toLower(variables('emailBodyVAR')), '<table'), 1)), '</table')), '</table>')

     

    However there will be better ways to process this information.

     

    Also, if the information isn't purely a mathematical issue, consider storing it in a SharePoint list, rather than an excel sheet. This will enable you to do much more with the information (include export it to excel if someone REALLY wants it there 😉).

  • Verified answer
    v-chenzhi Profile Picture
    Microsoft Employee on at

    Hi @rhys87,

     

    I assume your email’s table has seven columns and two rows.

    As mentioned by @rhys87, we could use

    concat('<table', first(split(first(skip(split(toLower(Body), '<table'), 1)), '</table')), '</table>')

     to get the content of the html table part.

    vzhichen_0-1635761590429.png

     

    And use Html to text action to convert html to text, Then use

    split(outputs('Html_to_text')?['body'],outputs('Compose_3'))[7] 

    to get Value1, probably like this

    vzhichen_1-1635761590432.png

    vzhichen_2-1635761590434.png

    vzhichen_3-1635761590434.png

     

     

    Best Regards,

    Zhi Chen

  • eliotcole Profile Picture
    4,390 Moderator on at

    @rhys87 & @v-chenzhi 

     

    I realised a while back one thing, and just now another.

     

    All of our answers thus far are not strictly valid, because HTML allows for a table to be made within a table.

     

    So you will need to caveat to whomever this is for that the following failure scenarios are true:

    1. Definite Failure - When there is a table within a table.
    2. Probable Failure - When there any <colspan¹ or <rowspan² tags.

     

    Example of a table in a table:

    nameGivennameFamilyfavouriteHtml
    JaneSmith

    Emboldened text like this.

    JohnJones

    Tables like this:

    header1header1header1
    entryAanswerAdataA
    entryBanswerBdataB

     

    The code for this (literally ripped from this post 😅😞

    <table border="1" width="100%">
    <tbody>
    <tr>
    <td width="14.197530864197535%"><strong>nameGiven</strong></td>
    <td width="16.54320987654321%"><strong>nameFamily</strong></td>
    <td width="69.25925925925927%"><strong>favouriteHtml</strong></td>
    </tr>
    <tr>
    <td width="14.197530864197535%">Jane</td>
    <td width="16.54320987654321%">Smith</td>
    <td width="69.25925925925927%">
    <p>Emboldened text like <strong>this</strong>.</p>
    </td>
    </tr>
    <tr>
    <td width="14.197530864197535%">John</td>
    <td width="16.54320987654321%">Jones</td>
    <td width="69.25925925925927%">
    <p>Tables like this:</p>
    <table border="1" width="100%">
    <tbody>
    <tr>
    <td width="33.333333333333336%"><strong>header1</strong></td>
    <td width="33.333333333333336%"><strong>header1</strong></td>
    <td width="33.333333333333336%"><strong>header1</strong></td>
    </tr>
    <tr>
    <td width="33.333333333333336%">entryA</td>
    <td width="33.333333333333336%">answerA</td>
    <td width="33.333333333333336%">dataA</td>
    </tr>
    <tr>
    <td width="33.333333333333336%">entryB</td>
    <td width="33.333333333333336%">answerB</td>
    <td width="33.333333333333336%">dataB</td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    </tbody>
    </table>

    As you can see, if we split as we have been doing, this will mean the first table will not close properly('legally'), especially if there are more rows below the table. If that table is on a page where there are two root level tables (with one or more having a sub table) then you are in even more trouble.

     

    To be clear, it's still doable, and I suspect some creative use of indexOf() and/or substring() could help here, but it will result in either huge expressions, or increased (and therefore slower) action steps, for sure.

     

    _________

    Footnotes:

    1. data spans multiple columns
    2. data spans multiple rows

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard