Question
3
Replies
1024
Views
Posted: June 29, 2018
Last activity: September 21, 2018
Closed
How to read the HTML email Body (MS Outlook) - Loop the Dynamic Table from the body
How to read the Microsoft office HTML email body and loop the dynamic row table from the body to create the folders in the Specific location for the all the Error Code. Refer the attached email example.
You'll need to write some custom code here.
If you are on a version of PRPC that contains a HTML 'Tag Soup' processing library (like 'Tag Soup' or 'JSoup') - you can configure your Email Service / Listener to use 'prefer HTML'; which should populate the '.pyBody' property with the entire HTML content of your email.
Then you can reference a post-processing Activity to examine the contents of the '.pyBody' property to extract the information you need.
This will most likely be a 'messy' exercise; with lots of exceptions to deal with - but its not impossible.
Here's an example (for PRPC73) of some Java Code using 'Text Soup' to process HTML emails - this example just 'strips' the HTML body of ALL elements and extracts text. (which is a destructive process; loses tables, images etc - but can be useful).
You should be able to adapt this to deal with TABLES/[TH|TR]/TD blocks in your HTML.....
It needs three 'local' variables (on the Parameter Tab of the Activity) set up:
And the 'Step Page' should be '.pyInboundEmail'.
You need to reference this Activity from your Email Service Rule.
Its one giant Java Step I'm afraid - which is very much outside of Guard Rails; so please understand the possible risks (to code maintainability etc) you are introducing by following an approach like this.
There's a lot of 'cruft' in here; but basically the important thing to note is that the 'Tag Soup' library looks like Standard SAX Parser (from the 'outside') ; it can take a 'messy' input document and try and output a well-formed HTML document - which you can then react to using SAX methods.