cancel
Showing results for 
Search instead for 
Did you mean: 

How to Extract table from HTML Mail body!!!

RaghunandanP_G
Level 2
We are working on reading mail content which has a table information. I use MS Outlook VBO, Get retrieved items method to read the mail content. Anyone has succeeded in extracting table from HTML mail body?


------------------------------
Raghunandan P G
Lead
Fidelity
Bangalore
------------------------------
8 REPLIES 8

ewilson
Staff
Staff
Hi @RaghunandanP_G,

What problem are you having? I've been able to use the actions on the Outlook VBO to retrieve the body of received emails in HTML format. 

25984.png
Once you have the HTML it's pretty much an exercise in parsing text. There are a few ways you can do that. You can go old school and just use string parsing to find the start and end tags of the table data and pull it out. Alternatively, you should be able to load the body into an XML parser, as I believe Outlook creates XHTML as opposed the plain HTML, and parse it using XPath.

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

VivekGoel
Level 10
Curious to know the type of emails you are trying to read. I can read everything but the notification emails (like delivery notification, meeting request accepted etc) using the standard VBO.

------------------------------
Vivek Goel
Winners of "The" RPACULT 2020
https://rpatools.com/2020/11/the-rpacult-2020-winners/
------------------------------

Hi Vivek,

GetReportItem action was recently added into the MS Outlook VBO to read delivery notification. It is available on DX.

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

BarışKarakaş
Level 2

​Hello,
I previously wrote such an action within my MS Outlook VBO I hope it helps.

If the table you are trying to read is always in the same format (maybe a table that your robot generates in the runtime) you can reverse calculate a collection from html body. I did this in one of my processes. You can use regex to get values that are in between <td> </td> and count the rows and columns (by counting the occurences of <tr> <th> tags) then dynamically create a collection with that info.
Hope it helps
Best,
Baris Karakas



------------------------------
Barış Karakaş
Process performance specialist
TEB
Europe/Istanbul
------------------------------

EVIPUTI
MVP
If you are getting the body in html format then based on the string operation you can able to fetch the table data.
eg.
if html mail contains html table code like,

HTML:
<table id="t01">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>
then just using string operation fetch the data from td and tr tag as per your requirement.

------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification and Optimization Designer(Solutions Architect)
Fidelity International
------------------------------
------------------------------
------------------------------ Vipul Tiwari Senior Process Simplification Developer Amazon ------------------------------

Hello,
I am also sharing my code that reverse calculates a datatable from very unformated simple <table> tags. Hope it helps. Copy and paste this code to the global code
You can use this in any code stage like shown:

string strVal = "<table><tr><td>Harry</td><td>Potter</td><td>12</td><td>1994</td></tr><tr><td>James</td><td>Hetfield</td><td>30</td><td>1969</td></tr><tr><td>Kirk</td><td>Hammet</td><td>87</td><td>1990</td></tr></table>";
DataTable dt = reverseTableTag(strVal); 
//dt is your collection output

------------------------------
Barış Karakaş
Process performance specialist
TEB
Europe/Istanbul
------------------------------

keerthi03
Level 2

I am trying to read the table from email body using Outlook VBO. Unable to extract table data. Need assistance

 

Hi @keerthi03 ,

Can you please share some more details as in what exactly is the issue. Are you not able to get the HTML table content itself or do you have problems while parsing the same. For parsing the content, like already people have suggested here you can use string manipulation or simply have some sort of a regular expression which can be used in a loop or the expression itself can identify patterns.

If you can share a bit on what exactly is the issue and how the HTML body looks like if you are getting one, then we can dig more into the same.

NOTE: If you are sharing screenshot, please ensure no confidential data is present in the same.

 

---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.