How to parse inbound email body text in HTML format?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 05:38 AM
Hi All,
I hope someone can help me; I am trying to create a requested item automatically from an inbound email. I have a third party tool sending email message to my instance which contains the below information. The email is in html format and I need to get the values of each element. The variable:value (e.g. email.body.variable) approach does not work here since on each line, I have the <p> </p> tags, I cannot amend the email to be sent as plain text; Can someone share a script to get each value of the below information and store in a variable? Thanks in advance!
<HTML><BODY><p>A termination is due to take place please find below the pertinent information to enable IT to close the account:</p>
<p>Termination Date:23/08/2019</p>
<p>Preferred Name:EE8 MM8</p>
<p>Employee Class:</p>
<p>Job Classification:</p>
<p>Job Title:</p>
<p>Manager ID:28002596</p>
<p>Country:CHN</p>
<p>Location:Shenzhen</p>
<p> </p>
</BODY></HTML>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 12:08 AM
Hello,
Refer below links for your query:
https://www.servicenowguru.com/system-definition/inbound-email-new-reply-forward/
Please mark correct & helpful; if it's useful to you.
Thanks & Regards,
Pooja Devkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2020 06:42 AM
Hello James,
Did you get the solution for this, if so can you please share me the code i have the similar requirement.
Thanks and Regards,
Bhavana

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2020 08:03 AM
Hi Bhavana,
I'm sure this is much later than anticipated and may not be relevant to you anymore, but I stumbled upon this thread and thought that I had the same issue. This thread had me believing that "value:variable" was not running on my HTML email format. I luckily had the ability to swap my e-mail to plaintext format but my log statements still showed my variable as "undefined" so I was going crazy.
WELL it turns out that inbound rules DO run on HTML emails. I just missed a clear note in the official ServiceNow document which was causing my issue...
Note: The action always generates a lowercase variable name. Also, this functionality does not work on reference fields.
May have been the same case in this thread if the inbound action was something like...
current.u_jobtitle = email.body.Job_Title; //would not work
current.u_jobtitle = email.body.job_titile; //would be correct as it is generated as a lowercase variable
Hopefully this helps someone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 07:41 AM
Hi James,
Did you get the solution for this?