Emails to multiple addresses auto-filled by a client template may end up as send ignored


Description

Symptoms

Emails end up as send-ignored if generated through the email client where a client template auto-fills more than one email address in any one of the To, CC, or Bcc fields.

Opening the email record shows the error:

SMTPSender: no recipients, email send ignored

Release

All releases.

Cause

The To, CC, and Bcc fields of an email client template are of type String. If you're using javascript to auto-fill more than one email address in one of these fields, you'll need to use an array to add the multiple addresses. Otherwise, the multiple email addresses will be concatenated as a single string and will not be a valid email address.

Resolution

In the To, CC, or Bcc field of an email client template, add the multiple email addresses to an array and join the array. Example:

javascript: var emailAddresses = [];
emailAddresses.push("test@example.com");
emailAddresses.push(current.caller_id.email);
emailAddresses.push(current.caller_id.manager.email);
emailAddresses.join();

Alternate solution:

If you plan to reuse this code in multiple email client templates, you can:

1. Create a new script include.
2. Check the Client Callable checkbox.
3. Add a function on line 3 of the Script field to build and join the array of email address. If dot-walking, you'll need to pass in the current object to the function. Example:

addEmailAddresses: function(current) {
var emailAddresses = [];
emailAddresses.push("test@example.com");
emailAddresses.push(current.caller_id.email);
emailAddresses.push(current.caller_id.manager.email);
return emailAddresses.join();
},

4. Click Submit.

5. In the To, CC, or Bcc field of the email client template, call the script include. If dot-walking, you'll need to pass the current object to the script include. Example:

javascript: new <_scriptIncludeName>().addEmailAddresses(current);