Forwarding an email received in Servicenow with Attachments

Nishant16
Tera Expert

I am using the below Business rule to forward any email received in Servicenow on a closed incident to itsupport@itisupport.com

find_real_file.png

(function executeRule(current, previous /*null when async*/ ) {

    var sysid = current.instance; //geting sys id of incident from target field
    var gr = new GlideRecord('incident');
    gr.addEncodedQuery("sys_id", sysid);
    gr.query();
    if (gr.next()) {
        var state = gr.state; //getting state value
    }
    if (state == '7') { //if state in closed

        var mail = new GlideRecord("sys_email");
        mail.initialize();
        mail.mailbox.setDisplayValue("Outbox");
        mail.recipients = ("tsupport@itisupport.com");
        mail.subject = ("Fw: " + current.subject);
        mail.body = (current.body);
        mail.type = "send-ready";
        mail.content_type = "multipart/mixed";
        mail.insert();
    }


})(current, previous);

my query is how can i add the attachments to this email i am forwarding as well?

3 REPLIES 3

Adrian Ubeda
Mega Sage
Mega Sage

Hi Nishant,

Have you tried to achieve this using inbound email actions? Check the docs: https://docs.servicenow.com/en-US/bundle/sandiego-servicenow-platform/page/administer/notification/concept/inbound-action-processing.html

You can create a rule for forwarding this kind of email that matches your conditions and attachment would be forwarded as well.

If it was helpful, please give positive feedback.
Thanks,

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Thanks for the response, but unfortunately i cannot find my answers in the link you shared

The attachment that you want to forward are attach into the incident or into this new incoming mail?

Thanks,

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆