- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 08:11 AM
Hi SNC,
As anyone managed to successfully set multiple Outbound Email Accounts according to Department?
For example, for a given email notification sent to user A regarding Facilities Request closure, tthe outbound email be presented as 'facilities@companyA.com'; and for an email notification sent to user B regarding Marketing Request closure, the outbound email be presented as 'marketing@companyB.com'?
Thanks in advance,
Fábio Gonçalves
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 10:46 AM
Hi Fabio,
I am not sure on your intent of having GR query on sysevent_email_action table, you have to create mail scripts under the 'Notification mail scripts' module
you have to use the email.setFrom in the mail script and use the email script in the notification as ${mail_script:<mail script name>}
http://wiki.servicenow.com/index.php?title=Scripting_for_Email_Notifications#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 08:58 AM
Hi Fabio,
You should be able to do that with a mail script,
email.setFrom('email@email.com');
additionally, you may want to set the forwarding rules/set reply to on the email (email.setReplyTo('email1@email1.com')), so you ensure the replies to the emails sent are received and processed (if you expect any inbound emails)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 10:30 AM
Hi Karthik,
Thanks for your help.
That is the Email script I created. But, for some reason, it do not work:
"
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var emailNotification = new GlideRecord("sysevent_email_action.list");
emailNotification.addEncodedQuery('active=true^collectionSTARTSWITHhr^ORcollectionSTARTSWITHfacilities^ORcollectionSTARTSWITHsn_sm_finance^ORcollectionSTARTSWITHsn_sm_legal^ORcollectionSTARTSWITHsn_sm_marketing');
emailNotification.query();
while (emailNotification.next()) {
if (emailNotification.collection.startsWith('hr')) {
email.setFrom('recruiting@example.com');
}
if (emailNotification.collection.startsWith('facilities')) {
email.setFrom('security@example.com');
}
if (emailNotification.collection.startsWith('sn_sm_finance')) {
email.setFrom('finance@example.com');
}
if (emailNotification.collection.startsWith('sn_sm_legal')) {
email.setFrom('legal@example.com');
}
if (emailNotification.collection.startsWith('sn_sm_marketing')) {
email.setFrom('marketing@example.com');
}
}
})(current, template, email, email_action, event);"
Any ideas?
Thanks in advance,
Fábio Gonçalves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 10:46 AM
Hi Fabio,
I am not sure on your intent of having GR query on sysevent_email_action table, you have to create mail scripts under the 'Notification mail scripts' module
you have to use the email.setFrom in the mail script and use the email script in the notification as ${mail_script:<mail script name>}
http://wiki.servicenow.com/index.php?title=Scripting_for_Email_Notifications#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 10:57 AM
Hi again Karthik.
Thank you again.
Just one last question: where should I se the email script in the notification as ${mail_script:<mail script name>}? In which field/section of the Email Notification should I include this code?
Thank you.
Fábio Gonçalves