mail_script email.addAddress not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2012 08:34 AM
I'm trying to add recipients to an email notification by using the following code (I copied this directly from the Wiki😞
<mail_script>
//email.addAddress(type, address, displayname);
email.addAddress("cc", "john.copy@example.com","John Roberts");
email.addAddress("bcc", "john.secret@example.com","John Roberts");
</mail_script>
But these addresses are not added. I would assume they should show up as recipients when I view the email in the System Logs but these addresses are not listed.
Am I missing something?
Thanks,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2012 08:57 AM
Hi Michael,
You will not see email added using code mentioned by you in email log. You are adding email address to "cc" and "bcc", email log reciepient shows email address mentioned in "to" .
Code you are using is used to overwrite the mail content and it will add cc/bcc not "to" person.
If you check the actual email, you will see email you added in "cc" field.
ND
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2012 10:29 AM
Yes, I see. I found that there's also a "Copied" and "Blind Copied" field I can add to the form to see those recipients from the logs as well.
Thanks for the quick response.
Another question: Any idea if there's a way to add a recipient to the "To" field from a mail_script? I tried email.addMessage("to", ...) but that didn't work. My issue is that I'm dynamically adding recipients to a notification and there may be times in which all recipients are added via the mail_script. I found that the notification is not even created if there are no "To" recipients.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2012 10:39 AM
You can't do same for "to" using mail_script.
If you want to add more email ID's use "watch List" feature ( I assume your table inhherit task table). Add user's you want to send email to watch list and in notification use "watch_list". I did same thing with code which is configured to add email ID's based on some criteria. Please check below code (in Business rule).
var userID = ;
if (current.watch_list.toString().indexOf(userID.toString()) == -1 ){
var watchListArr = current.watch_list.toString().split(',');
watchListArr.push(userID.toString());
current.watch_list = watchListArr.toString();
}
ND
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 10:05 AM
This is a old post, however here is how I solved this issue. email.addAddress didn't work for me.