Outbound email integration

sunitkapure
Tera Contributor

i want to configure outbound email integration in ServiceNow so that emails can be sent to multiple Gmail IDs based on the priority of the ticket.

 

If the priority is High, the email should be sent to the Manager’s Gmail ID(s)

If the priority is Low, the email should be sent to the Employee’s Gmail ID(s).

Please guide me step-by-step on how to implement this outbound email setup in ServiceNow, including how to add multiple recipients and how to apply conditions based on priority.

2 REPLIES 2

Bhavya11
Kilo Patron
Kilo Patron

Hi @sunitkapure ,

 

Here simply steps to achieve this.

1. goto Notification[sysevent_email_action]  table, create new record and select appropriate table

 For Example :Incident

Bhavya11_0-1764571207819.png

2. When to send to tab; add the condition

Bhavya11_1-1764571284165.png

3. who will receive tab; you can add any field value  for example caller

Bhavya11_2-1764571307638.png

4. goto Email Script [sys_script_email] create new record using  below script; you can change cc from to as per your requirement 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

         // Define the Manager's Gmail IDs (High Priority Recipients)
    var managerEmails = ["bhavya.karanth@mail.com", "manager2@gmail.com"];

    // Define the Employee's Gmail IDs (Low Priority Recipients)
   var emailEmployeeAddresses = ["user1@example.com", "user2@example.com", "user3@example.com"];

    // Check the current ticket's priority value
    var priority = current.priority; 

    
    if (priority == 1 || priority == 2) {
        // High Priority: Send to Managers
       
		for (var i = 0; i < managerEmails.length; i++) {
        // Add each email address to the BCC list
        email.addAddress("cc", managerEmails[i]);
    } 
        email.setSubject(current.getDisplayValue('priority')+" Priority Ticket: " + current.number + " (" + current.short_description + ")");
    } else if (priority == 4 || priority == 5 || priority == 3) {
for (var i = 0; i < emailEmployeeAddresses.length; i++) {
        // Add each email address to the BCC list
        email.addAddress("cc", emailEmployeeAddresses[i]);
    }        
        email.setSubject(urrent.getDisplayValue('priority')+"Low Priority Ticket: " + current.number + " (" + current.short_description + ")");
    }
})(current, template, email, email_action, event);

5. What it will contain section

Bhavya11_3-1764571347983.png

 

The priority for ticket ${number} has been set/changed.

${mail_script:ticket_priority_recipients} 



Details:

Short Description: ${short_description}
Priority: ${priority}

 

 

If this information proves useful, kindly mark it as helpful or accepted solution.

 

Thanks,

BK

 

 

its not fully working can please guild me can we have one call on google meet in your free time