Parsing .eml/.msg email attachments

geoffluk
Tera Contributor

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!

9 REPLIES 9

Thanks @lior grinberg for sharing the project.

However, my usecase is to parse the email(.msg) file attached to a RITM# record(sc_req_item table). I've used the following script:

var gr = new GlideRecord('sys_attachment');
var sa = new GlideSysAttachment();
var stringUtil = new GlideStringUtil();

gr.addEncodedQuery('table_name=sc_req_item^table_sys_id='+current.sys_id);
gr.query();
while(gr.next())
{
var binData = sa.getBytes(gr);
var encData = stringUtil.base64Encoe(binData);
var data_string = stringUtil.base64Decode(encData);
gs.print(data_string);
}

The output I'm receiving as - 

�w^~)�


The body of the .msg file contains the following text - 'This is the content.'

Can you please let me know where I'm going wrong.

Thanks,

Bhavana

Hi,

For .msg files you cannot use this command.

You need to use this application: 

https://store.servicenow.com/sn_appstore_store.do#!/store/application/2651741c1b9008504a16db56dc4bcb30

 

Best regards,

Lior grinberg

Thanks @lior grinberg 

As far as I've understood, the Data Extract application is licensed. Can you please provide more insight on Data Extract about how it works as I was not able to find any documentation for it? 

Can you please let me know if there is any other alternative available which is free of cost?  

 

Khushbu5
Kilo Explorer

Hi Tippireddy - Were you able to solve this?

I am looking for same scenario

Hi Khushbu,

No, as the Data Extract application is licensed and we couldn't find any other alternative we dropped the requirement.