Parsing .eml/.msg email attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2019 12:14 PM
Hi all,
So it's been asked, and answered, whether or not we can parse email attachments that are CSV or Excel file formats. However, we have a business requirement to instead parse .eml or .msg email attachments.
The general purpose of this is to parse the attached .eml/.msg file, check for a specific key-value pair in the HTML body (or in the header) of the attachment, and then process the original inbound email accordingly.
I understand that this is already something that is taken care of by Security Incident / Security Incident Response functionality, but we do not currently use this feature. Right now we need something that is more generic that allows us to handle these .eml and .msg via inbound Incident creation.
Thanks!
- 2,537 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 10:08 PM
Hello Geoffluk,
You can use ParseAttachmentAsAnEmail platform api to parse the .eml or .msg email attachments. It will give you a json containing observables.
Example :
var emailJSON = ParseAttachmentAsAnEmail.parse(attachmentGr);
You can retrieve info from emailJSON as listed below
- emailJSON.headers()
- emailJSON.body_html
- emailJSON.body_text
- emailJSON.subject
- emailJSON.from()
- Get file/sha256 from attachments
for (var i = 0; i < emailJSON.parts().length; i++) {
some var = processing emailJSON.parts()[i]);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2020 03:55 AM
Hi Kavi,
I tried to use your code but I'm getting an error for using "ParseAttachmentAsAnEmail" the error is "
"ParseAttachmentAsAnEmail" is not defined."
What I'm doing wrong?
Thanks,
Lior grinberg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2020 05:25 AM
Hi
I'm facing the same issue, were you able to find the issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2020 11:06 PM
Hi,
I solved the problem with a different command.
I created a small project in Share for that.
You can download it and look on the solution there:
https://developer.servicenow.com/connect.do#!/share/contents/8295848_undelivered_email?v=1.0&t=PRODUCT_DETAILS
Best rgerads,
Lior grinberg