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
------------------------------
6 REPLIES 6

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
------------------------------