Not able to send email to email.from as well as email.CC using gs.eventQueue()

spimple
Tera Contributor

I have a scenario in which if i get a email from customer to create a case. Then I trigger a event which triggers the notification to send the email body.

 

I have tried below code:

if (contact.next()) {
if (contact.account.u_account_segment == 'Small Enterprise') {
gs.eventQueue('event_name', null, null, email.from);
var ccEmails = email.CC.split(",");

for (var i = 0; i < ccEmails.length; i++) {
gs.eventQueue('event_name', null, null, ccEmails[i].trim());
}
}
return;

}

 

but i am only able to send the email to email.from . I am not getting the emails for CC people

 

 

what should i modify so that i get emails for email.from and email.CC people 

 

 

8 REPLIES 8

Hello @Sohail Khilji , Can you please tell me what should i do with the gs.eventQueue
Can i trigger event in inbound email actionn and write gs.eventQueue(eventName, current, email.from,email.copied)

and after doing this can i call these two parameters in my email script ?? if yes can you please tell me how ?

actuall before this i was calling email.from and email.copied in two diffrent queues but i have been told that i need to send the email to email.from and email.copied at once 

Sohithanjan G
Kilo Sage
Kilo Sage

Hi @spimple ,

 

For that create an email script as addemails. In the mailscript add below code, to add cc & bcc.

email.addAddress('cc','abc@gmail.com','Test user');
email.addAddress('bcc','abc123@gmail.com','Test user123');

 

 

Now, In your notification of choice, include below mail script

${mail_script:addemails}


HIT helpful & Accepted Solution !! 

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)

Hello @Sohithanjan G , The thing is i dont want to add emails as hardcoded , I am getting those email id from inbound email action and i need to pass those while triggering the event and I need to use email.from and email.copied  in the email script so how do i use those params in email script?
gs.eventQueue(eventName, current, email.from, email.copied) this is i am using in inbound email action

Hi @spimple 

In ServiceNow, the gs.eventQueue() method is primarily used for sending events to the event queue, which is typically used for asynchronous processing. It's not directly related to sending emails, and it doesn't support sending emails with CC (Carbon Copy) or BCC (Blind Carbon Copy) recipients.

If you want to send emails with CC or BCC recipients in ServiceNow, you would typically use the GlideEmailOutbound API. Here's a basic example of how you can send an email with CC and BCC recipients in ServiceNow:

 

// Create a GlideEmailOutbound object
var email = new GlideEmailOutbound();

// Set the sender's email address
email.setFrom("sender@example.com");

// Set the subject of the email
email.setSubject("Test Email");

// Set the body of the email
email.setBody("This is a test email.");

// Add recipients
email.addRecipient("recipient1@example.com");
email.addCC("ccrecipient@example.com");
email.addBCC("bccrecipient@example.com");

// Send the email
email.send();

 

 

Mark Helpful & Accept Solution !!!

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)