Mail Scripts and the email Object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2010 08:24 AM
I'm working on a complex email notification and I'm looking for information on the "email" object that's available from within mail_script tags. My immediate concern is updating/overriding the recipient list of the generated sys_email record. So far I've managed to dump the members/method names of the email object (instance of Java class EmailOutbound) and start cobbling together a little API for it. Unfortunately, it seems like many of the setter methods don't to do anything. Can someone shed light on the following methods, or direct me to the API for the class com.glide.notification.outbound.EmailOutbound? My hope is that I'm just passing in the wrong parameter types, since I'm guessing them. Thanks much.
addAddress()
setAddress()
setRecipients()
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2012 09:32 AM
I can add the mail_script code in the notification email to go thru the watch list and get any email addresses on the watch list and send to them BCC, but not CC. Seems like a weird bug to me. Anyone else experiencing the same thing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2012 10:44 PM
Can you share the code you are trying?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2012 06:42 AM
The cc not working was a know issue, it was corrected with the latest hot fix in Berlin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2012 02:52 PM
So it came to my attention that the script provided to add users to the CC or BCC list only worked if the recipient exists as a SN user. An external email address would not get put on the CC list since it would come across as an actual email address instead of a sys_id.
So I redid the script to be able to add both SN users (via sys_id) and, if an external email address is added, that address will be included in the CC list as well. It does so by checking to see if there is an "@" symbol in the string. If there is, it's an external address. If not, it is a SN user and is a sys_id. Here it is (the code IS actually formatted nicely but it seems the forum unceremoniously unformats it) :
if (!current.watch_list.nil()) {
//get watch list addresses and add to cc
var watchers = current.watch_list.split(",");
var wl = watchers.length;
for (var i = 0; i < wl; i++) {
if (watchers.indexOf("@") != -1) {
email.addAddress("cc", watchers, "");
} else {
//get user records
var user = new GlideRecord("sys_user");
user.addQuery("sys_id", watchers);
user.addQuery("notification", 2); //email
user.addQuery("email", "!=", "");
user.query();
while (user.next()) {
//add to cc list
email.addAddress("cc", user.email, user.getDisplayValue());
//email.addAddress("bcc", user.email, user.getDisplayValue());
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2012 09:03 AM
Thanks for a great piece of code. You've saved me a lot of time, however it doesn't seem to work for anyone subscribed to the notification. Does anyone know how to also look through the cmn_notif_message table to BCC (not yet on Berlin, pinned instance until January)? We have added users, as subscribers rather than adding them directly to the notification to make administration easier, and some have close to 2K users (for now, we have them split onto duplicate notifications).
Berlin fixes a lot of this, but not the cc/BCC issue for subscribers.