I have been trying to send to multiple recipients but to no avail. Currently I define a transform to split then join the recipient string then pass it to the email connector, but it fails saying
Error while sending email: Error while creating email1@domain.com,email2@domain.com InternetAddress
The original transform is defined as below:
if((emailString as String) contains "," )
(emailString as String) splitBy "," joinBy ","
else if(emailString != "" and emailString != null)
[emailString]
else
null
I am wondering if there is a bug or special case I have not seen while checking the documentation.
You are splitting the string containing emails addresses but then you are joining the resulting items back into a string. Just pass the resulting array to the connector. You probably don't need the other cases. splitBy()
already returns a single element if the split character is not found and returns null if the input is null.
Example:
<email:send toAddresses="#[vars.emailString splitBy(",")]" ... >
Reference: https://help.salesforce.com/s/articleView?id=001114454&type=1