Extract value from the HTML body of an Email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-11-20 01:20 PM
Hello,
I have a question regarding the following table:
Name |
Number |
Hours |
Date |
Approve? (Y/N) |
Maria |
123 |
8 |
11/16/2020 |
Y |
Ana |
456 |
10 |
11/16/2020 |
N |
I read this table from the HTML body of an Email, so I have to work with the HTML format of the table.
I want to extract the value of the last column with "Y" or "N". Also, I want to know for which name is approved or not.
Any ideas on how should I do that?
Thanks a lot,
------------------------------
Madalina Acsinte
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-20 10:25 AM
HTML is usually tricky. Is that format of the table always the same? If it is then you can read email (including HTML code), do some text splitting using HTML elements and then loop on rows.
------------------------------
Michal Szumski
RPA developer
Rockwell Automation
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-20 02:37 PM
------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-20 04:31 PM
If you able to extract that data into BP collection then you can apply the filter from Business Object: Utility - Collection Manipulation, Action: Filter Collection
Please find below url for filter criteria
------------------------------
Shashikant Patil
Senior Associate
Cognizant
America/New_York
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-20 05:54 PM
HtmlAgilityPack.dll is part of blueprism, so you can do something like this:
// Ref: HtmlAgilityPack.dll, System.Core.dll
// NS: HtmlAgilityPack, System.Linq
// In:html (Text), Out:dt (Collection)
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
dt = new DataTable();
HtmlNode table = doc.DocumentNode.SelectNodes("//table")[0]; // Pick first table
HtmlNodeCollection headers = table.SelectNodes("//tr/th"); // Headers
// Columns
foreach (HtmlNode header in headers)
dt.Columns.Add(header.InnerText, typeof(string));
// Rows
foreach (HtmlNode row in table.SelectNodes("//tr"))
dt.Rows.Add(row.Descendants("td").Select(td => td.InnerText).ToArray());
Assuming table has headers and no colspans, this should work with any number of columns/rows.
------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-20 09:38 PM
I think parsing HTML with HtmlAgilityPack.dll is a great idea. Can you please provide the download source?
------------------------------
Shashikant Patil
Senior Associate
Cognizant
America/New_York
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-20 10:05 PM
The download link will send you to nuget; if you download the package, the DLL file should be in there.
------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-20 11:04 PM
Either way, Nicholas provided download link already. nupkg file is just zip archive.
------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-12-20 02:27 PM
Could you please provide me the bp release file of the above html parsing code? I have similar requirement where I want to read the first table from the body of email.
Thanks
Ashis
------------------------------
Ashis Kumar Ray
RPA Developer
TCS
Europe/London
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-12-20 02:01 PM
This is mostly a proof of concept. I left both linq and nonlinq code stages just in case.
------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------
