How to use var email = new GlideEmailOutbound();

dev115415
Tera Expert

Hello I want to send an email from ServiceNow script include. The sender of email id will be for example sender1@gmail.com and receiver as receiver2@gmailcom. Can we use 

var email = new GlideEmailOutbound(); for this? How to use this.

7 REPLIES 7

First step your script needs to be under Global application.

then try to use this sample script it works well for me 

var email = new GlideEmailOutbound();
email.setSubject("Email subjct");
email.setBody('The Email Body');
email.setFrom('set the from here');
email.addRecipient('recipient');
email.save();

 

 

HAMDI Oussema
Tera Contributor

First step your script include needs to be under Global application.

then try to use this sample script it works well for me 

var email = new GlideEmailOutbound();
email.setSubject("Email subjct");
email.setBody('The Email Body');
email.setFrom('set the from here');
email.addRecipient('recipient');
email.save();

 

Amit Verma
Kilo Patron
Kilo Patron

Hi @dev115415 

 

You can use GlideEmailOutbound() API for this provided you don't want to send any attachment with the email. It is a scoped API for which documentation is available on https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/G...

 

You can refer to it and set your script accordingly.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.