Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Sending email with attachment from external email

kim-lindgren
Kilo Sage

Is there an inbuilt limitation for sending email attachments from an external email address? We have a requirement to do this but it is not working, the email is sent but not the attachment.

 

I have checked that the attachments being sent are not too large compared to what is allowed in the system properties.

 

Best regards,

Kim

2 REPLIES 2

Nikhil Soni 007
Giga Guru

Hello, 

 

If the requirement is on top most priority then only I would suggest this approach to follow as I have implemented this in the past.

 

1) Create Business rule on sys_email table

2) Put some condition in when to run so that script don't run for every record depends upon your requirement.

3) In Script please use:

 

var grAtt = new GlideRecord('sys_attachment');
grAtt.addEncodedQuery('table_name=your_table_name^table_sys_id=' + current.sys_id);
grAtt.query();
while (grAtt.next()) {
var attContent = new GlideSysAttachment().getContentStream(grAtt.sys_id);
new GlideSysAttachment().writeContentStream(current, grAtt.getValue('file_name'), grAtt.getValue('content_type'), attContent);
}

 

please mark this correct If it is helpful!

 

 

kim-lindgren
Kilo Sage

We will create a workaround instead so I will not be testing your suggested solution but thank you anyway for your help.