Get Email Attachment Name in Inbound Action

Tomoaki Tagawa1
Tera Contributor

Hi all,

I would like to get attachment file name in my inbound action which makes incident.

Is it possible?

* I think this is impossible... because inbound action is unable to get email attachment file name,

and even if sys_attachment can be queried, there isn't no attachment because at that time inbound action haven't made incident yet.

 

ANY help is welcome.

 

Best regards,

Tomoaki

1 ACCEPTED SOLUTION

Kushagra Mehrot
Kilo Guru

Hi,

 

Try this!

{slight change in uday's script}

var attachmentName = '';
var test = sys_email.sys_id;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name','sys_email');
gr.addQuery('table_sys_id',test);
gr.query();

if(gr.next()){
attachmentName = gr.file_name;
}

 

Thanks
Kush

 

 

Please mark the answer correct/helpful accordingly!

 

 

View solution in original post

6 REPLIES 6

Kamal17
Kilo Sage

Hi,

Haven't tested this but try below script to fetch attachment name.

var emailSysId = '';//sys id of the email received
var attachmentName = '';

var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name','sys_email');
gr.addQuery('table_sys_id',emailSysId);
gr.query();

if(gr.next()){
attachmentName = gr.file_name;
}

Mark Correct if this solves your issue. Hit Like/Helpful based on the impact.

Regards,

Udhay

To fetch sys id of the email inside the inbound script you can use "email.recipients_array", one of the values stored in this array is the 'sys_id' of the email record in the 'sys_email' table.
For more information you
may also refer the docs URL or community post,

Mark Correct if this solves your issue. Hit Like/Helpful based on the impact.

Regards,

Udhay

 

Kushagra Mehrot
Kilo Guru

Hi,

 

Try this!

{slight change in uday's script}

var attachmentName = '';
var test = sys_email.sys_id;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name','sys_email');
gr.addQuery('table_sys_id',test);
gr.query();

if(gr.next()){
attachmentName = gr.file_name;
}

 

Thanks
Kush

 

 

Please mark the answer correct/helpful accordingly!

 

 

Shishir Srivast
Mega Sage

I think it's tricky to achieve that, or may be not possible, what is the business use case here?