How to set "Who will receive" through mail script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2014 11:13 PM
Hi Everyone,
I want to add "Who will receive' from <mail_script></mail_script>. is there any way by which we can set user/group filed in "Who will receive".
I m writing this code as below in <mail_script> in email template. But this is not working:
<mail_script>
var gr = new GlideRecord("change_request");
gr.addQuery("number", current.number);
gr.query();
if(gr.next())
{
var emailto=gr.requested_by.user_name+"@example.com";
email.setTo(emailto);
}
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2018 12:57 AM
Hi stmurphy,
Thanks for your code sharing. I also have a similar requirement, but I need to add an email address, instead of a user. Reason is that I need to force (and test if exists) a secondary email address.
When I try to add this email to "recipient_users, it doesn't work. I tried your code (to add an email address):
email_action.recipient_users += ",test@test.com,";
I even tried (to replace existing users/emails addresses):
email_action.setValue('recipient_users',mailaddress);
Paradoxaly, logging displays correctly the email address that I set by script:
gs.log('resulting recipient_users : '+email_action.recipient_users);
But when I look to sys_email, recipiends are not good (as if my code wasn't executed).
Is there any complementary action to apply, configuration to verify ?
Tried on OOB dev instance (Jakarta) and another one, unsuccesfully.
Thanks,
Arnaud
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2020 12:22 AM
Hi ,
I have the same requirement of sending a secondary OOB email to a email address "abc@gmail.com". Please help me out with this email script.
Thanks,
Lavanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2020 07:19 AM
Lavanya,
I think you can only use a user account with this. If you make a user account with this email address then supply the sys_id of that user it should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2020 07:21 AM
Lavanya,
You can cc email addresses that are not users in the system by using the email object.
https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/script/server-scripting/reference/r_ExScptEmlNtfn.html