cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CharlesBrewer
Responsive Resident
Responsive Resident

Send Data in a table in email

Hello,

So I am using Automate Desktop to webscrap some data. It will filter it, and then look something like this :

CharlesBrewer_0-1652206819480.png

I am trying to extract that data, and then send it in an email, but I also need it to kind of look like a table so it's readable. Instead it looks like this :

CharlesBrewer_1-1652206945317.png

It's hard to read, and it's adding commas. What I tried to do is to just a column at a time, to separate the data in columns into different variables, and I tried adding table rows into the email with HTML, but then I just get this : 

CharlesBrewer_2-1652207077765.png

Closer, but then I need each piece of data on it's own line. I'm not sure how it would look either if I tried to add in all 8 columns.

 

Any thoughts on how to achieve this? Thanks. I am very new to automate so talk to me like, well, I'm very new to automate 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
VJR
Multi Super User
Multi Super User

Assuming you have got all your required data from the website into the Datatable called DataFromWebPage

 

VJR_0-1652501814316.png

 

No need to use the List if everything is in the Datatable

 

Take 1 variable called TableHeader which contains the header of the html table. You can add your own table styles here like width etc.

VJR_2-1652502867452.png

 

 

 

Then another called TableBody which is generated dynamically within the loop as below

 

VJR_1-1652502695813.png

 

and then after the loop close the table by using </table> to the header and body.

 

In line 7 concat all 3.

FullTable = Header + Body  + </table>

 

This is the FullTable html generated after running the process.

 

 

<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>

<tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
</tr>

<tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
</tr>

<tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
</tr>

<tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
</tr>

<tr>
    <td>Laughing Bacchus Winecellars</td>
    <td>Yoshi Tannamuri</td>
    <td>Canada</td>
</tr>

<tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
</tr>

</table>

 

 

whose output looks as below when run in an html editor

 

VJR_3-1652502949464.png

You need to use the FullTable variable in your Send email with Html turned on.

 

Here is the full code of the sample flow.

Copy paste it into a blank flow and check.

 

 

 

@@timestamp: '03/15/2022 02:52:32'
@@source: 'Recorder'
@@culture: 'en-US'
WebAutomation.LaunchChrome.AttachToChromeByUrl TabUrl: 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro' AttachTimeout: 10 BrowserInstance=> Browser
WebAutomation.ExtractData.ExtractHtmlTable BrowserInstance: Browser Control: $'''html > body > div:eq(4) > div:eq(3) > div > div > iframe > html > body > table''' ExtractionParameters: {[$'''Value #1''', $'''Value #2''', $'''Value #3'''], [$'''''', $'''''', $''''''] } PostProcessData: True ExtractedData=> DataFromWebPage
SET TableHeader TO $'''<table border=1>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>'''
LOOP FOREACH CurrentItem IN DataFromWebPage
    SET TableBody TO $'''%TableBody%
<tr>
    <td>%CurrentItem['Value #1']%</td>
    <td>%CurrentItem['Value #2']%</td>
    <td>%CurrentItem['Value #3']%</td>
</tr>
'''
END
SET FullTable TO $'''%TableHeader%
%TableBody%
</table>'''
Display.ShowMessageDialog.ShowMessage Message: FullTable Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed

# [ControlRepository][PowerAutomateDesktop]

{
  "ControlRepositorySymbols": [],
  "ImageRepositorySymbol": {
    "Name": "imgrepo",
    "ImportMetadata": {},
    "Repository": "{\r\n  \"Folders\": [],\r\n  \"Images\": [],\r\n  \"Version\": 1\r\n}"
  }
}

 

 

 

You might need to add the variables.

VJR_4-1652503210812.png

 

Also the UI elements wont get copied but you need to extract the full table as shown earlier.

Also I have shared the URL of the sample website I am using, it is in the Launch action.

 

VJR_5-1652503404259.png

 

 

 

 

View solution in original post

10 REPLIES 10
CharlesBrewer
Responsive Resident
Responsive Resident

So I've been testing with just 2 columns and I got it to work (yay).  I don't know if this is at all the most efficient, and hopefully tomorrow when my brain is less dead I can get the other columns in. But here is what I did in pictures.

So I did a replace text and put into list to get half the html

CharlesBrewer_0-1652218184944.png

 

And then the other half is in the email : 

CharlesBrewer_1-1652218231637.png

 

And it got me this, like I wanted : 

CharlesBrewer_2-1652218310867.png

 

 

 

CharlesBrewer
Responsive Resident
Responsive Resident

This isn't actually working. It had the illusion of working because all of data in the 2nd column is the same. It's actually just taking the same text and putting it in all 3 cells. So yeah I have no idea what I'm doing 😞 Any help here is appreciated I've been stumped for several days.

VJR
Multi Super User
Multi Super User

Hi @CharlesBrewer 

 

Instead of looping into individual columns like ID and Status, use the "Extract data from webpage" to form a datatable of all the columns at once. This is possible when you capture the same fields at least twice (ie; ID) when you are using the "Extract data from webpage" on the website. PAD automatically converts it into a datatable when you capture at least two same elements. Then capture the Status on the website without using any new action and without closing the same Live web helper.

 

Once you get this datatable then loop through it and within the loop you need to pass the loopcolumns between the html tr and td tags.

 

Take a look at the 2nd approach in this direct link to the post here.

 

Also another post here.

 

 

Hello and thanks for the reply, 

So I was having some trouble because the table is in an iframe. I got around that now though and I have it stored as Datafromwebpage. 

CharlesBrewer_0-1652368772795.png

 

I don't really understand how to setup the loop, The loop wants a number for start and end but I don't know what it is? It's not going to be a static number, of course. I looked at the pages you linked but they just vaguely say 'use a loop' Can you perhaps show me how to setup the loop?  Also is there a way to manually add column headers? When I try to take the column headers off the web data it puts them into a separate column (and the text is wrong anyway).  Any help here is appreciated.

Hi @CharlesBrewer 

 

Use a loop on a datatable means to use the "For each" loop which automatically detects the total number of rows in the datatable. Simply drag a "For each" and pass the name of the Datatable.

 

Regarding the second question:

During the Extraction when you use the Live web helper, right click and when you select the below option of entire html table it captures along with the column headers.

VJR_0-1652411270713.png

 

 

On running the Datatable will have the column headers.

 

VJR_1-1652411370071.png

 

CharlesBrewer
Responsive Resident
Responsive Resident

I guess I am confused to what I'm supposed to do with the Loop still. I tried this : 

CharlesBrewer_0-1652450711434.png

But of course this not separate the columns, and I end up getting :

CharlesBrewer_1-1652450759239.png

 

I don't understand how to tell it to separate each piece of data, I guess, and make the rows and columns? Like I said I'm new to the program so if you can be a bit more specific please I would very much appreciate 😕

 

As for the 2nd part, I can't just extract the table because I don't actually want all the data, and when I do do that I get some weird function code. But I figured I could do the column headers in the email, which is what I was attempting in the above picture, with this :

CharlesBrewer_2-1652450886652.png

I hate to be such a bother but if you can lay this all out for me I'd be able to see it and understand it better, I imagine there's some steps or something that are simple to you but not to me and I am missing them.

CharlesBrewer
Responsive Resident
Responsive Resident

Before my day ends I was messing around with it more. I assumed I had to somehow Identify the columns in the loop so it does the individual data. I was trying this :

CharlesBrewer_0-1652477623165.png

But needless to say that didn't work. Going by my other picture, the columns are just named Value#1, Value#2, 3 and 4...so I tried variations of that too and did not work. I hope I'm getting closer? 🙂

 

VJR
Multi Super User
Multi Super User

Assuming you have got all your required data from the website into the Datatable called DataFromWebPage

 

VJR_0-1652501814316.png

 

No need to use the List if everything is in the Datatable

 

Take 1 variable called TableHeader which contains the header of the html table. You can add your own table styles here like width etc.

VJR_2-1652502867452.png

 

 

 

Then another called TableBody which is generated dynamically within the loop as below

 

VJR_1-1652502695813.png

 

and then after the loop close the table by using </table> to the header and body.

 

In line 7 concat all 3.

FullTable = Header + Body  + </table>

 

This is the FullTable html generated after running the process.

 

 

<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>

<tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
</tr>

<tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
</tr>

<tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
</tr>

<tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
</tr>

<tr>
    <td>Laughing Bacchus Winecellars</td>
    <td>Yoshi Tannamuri</td>
    <td>Canada</td>
</tr>

<tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
</tr>

</table>

 

 

whose output looks as below when run in an html editor

 

VJR_3-1652502949464.png

You need to use the FullTable variable in your Send email with Html turned on.

 

Here is the full code of the sample flow.

Copy paste it into a blank flow and check.

 

 

 

@@timestamp: '03/15/2022 02:52:32'
@@source: 'Recorder'
@@culture: 'en-US'
WebAutomation.LaunchChrome.AttachToChromeByUrl TabUrl: 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro' AttachTimeout: 10 BrowserInstance=> Browser
WebAutomation.ExtractData.ExtractHtmlTable BrowserInstance: Browser Control: $'''html > body > div:eq(4) > div:eq(3) > div > div > iframe > html > body > table''' ExtractionParameters: {[$'''Value #1''', $'''Value #2''', $'''Value #3'''], [$'''''', $'''''', $''''''] } PostProcessData: True ExtractedData=> DataFromWebPage
SET TableHeader TO $'''<table border=1>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>'''
LOOP FOREACH CurrentItem IN DataFromWebPage
    SET TableBody TO $'''%TableBody%
<tr>
    <td>%CurrentItem['Value #1']%</td>
    <td>%CurrentItem['Value #2']%</td>
    <td>%CurrentItem['Value #3']%</td>
</tr>
'''
END
SET FullTable TO $'''%TableHeader%
%TableBody%
</table>'''
Display.ShowMessageDialog.ShowMessage Message: FullTable Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed

# [ControlRepository][PowerAutomateDesktop]

{
  "ControlRepositorySymbols": [],
  "ImageRepositorySymbol": {
    "Name": "imgrepo",
    "ImportMetadata": {},
    "Repository": "{\r\n  \"Folders\": [],\r\n  \"Images\": [],\r\n  \"Version\": 1\r\n}"
  }
}

 

 

 

You might need to add the variables.

VJR_4-1652503210812.png

 

Also the UI elements wont get copied but you need to extract the full table as shown earlier.

Also I have shared the URL of the sample website I am using, it is in the Launch action.

 

VJR_5-1652503404259.png

 

 

 

 

CharlesBrewer
Responsive Resident
Responsive Resident

Thanks that worked 🙂 Mostly I needed to know the 

<td>%CurrentItem['Value #1']%</td>

part because I did knot how how to reference the columns in the rows and I was definitely doing the syntax so very wrong. But appreciated, it seems to be working. 

One more question for my own learning process if you don't mind. Why make the table header and closing table tag as variables, and not just put those in the email? Does it change the speed or anything or just a personal preference?

The table header and footer can also be added directly while sending the email. It is only for better readability for any developer to understand the code easily.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (2,053)