- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 11:43 AM
Can I set the 'TO' address in an mailto script? It reads from the system property, but I only want to change it for a specific email, not system wide. Let's say I want it to go to my personal email instead of the system email. This is NOT for a reply email - it is for a mailto: link in my email.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 11:08 AM - edited 03-18-2025 11:10 AM
Hello @Terri Welch
Dummy email script
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var approverEmail = "abc@gmail.com"; // Replace
var subject = "Project Approval Decision";
// Generate mailto links with action in the subject - please modify them as per your requirement
var acceptLink = 'mailto:' + approverEmail + '?subject=' + encodeURIComponent(subject + ' - Accept');
var deferLink = 'mailto:' + approverEmail + '?subject=' + encodeURIComponent(subject + ' - Defer');
var declineLink = 'mailto:' + approverEmail + '?subject=' + encodeURIComponent(subject + ' - Decline');
// Output the links for use in the email body
template.print('<p>Click below to respond:</p>');
template.print('<p><a href="' + acceptLink + '"> Accept</a></p>');
template.print('<p><a href="' + deferLink + '"> Defer</a></p>');
template.print('<p><a href="' + declineLink + '"> Decline</a></p>');
})(current, template, email, email_action, event);
You can modify this dummy script to have different email address for accept, defer and decline.
Dummy Email Notification Message HTML
Hi
To waste your time, a request has been submitted to you for accept/reject/defer by clicking on one of the options below:
${mail_script:dummy_script}
Thanks
ServiceNow
Validation results:
Hope that helps!
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 07:59 PM - edited 03-17-2025 09:00 PM
Hello @Terri Welch
If there is a TO email set in the e-mail notification and you want to set the same in your mailto script used in same email notification in message html then I believe it is not possible, however can be achievable using event registry (an example shared here: https://www.servicenow.com/community/itsm-forum/how-to-automate-for-notifying-if-a-task-isopened/td-...
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 08:15 PM
can you try this in your email script?
var emailAddress = "user@example.com";
var name = "User Name";
email.setEmailTo(emailAddress, name);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 09:26 PM
Hi @Terri Welch
You can make use of
email.addRecipient("user.name@example.com"); // replace with your to email ID
to set the To Email address. It is working as expected. Refer below screenshots -
Please give it a try and let me know the results.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 10:28 AM
Here is the situation:
I have a notification that has the following links:
These links are created with 'mailto script' in the notification:
When the link is clicked in the email - I need to set the TO address. Currently it is being set by a system property (I cannot change the system property - this is ONLY for this one notification)
The mail_script did not work with in the mailto Template or the original email.