how to get 2 email-addresse in property "To" from function sendEmail()

Viewed 36

i use script smtp.js. There is a property "To" in the documentation it says i need to enter an array.

I tried To: ['receiver1@email.tld', 'receiver2@email.tld'],

That does not work. I am looking for the right syntax with no luck so far, anyone a hint please?

Regards, Jan

1 Answers
function sendEmail(toemail=[]) {
  Email.send({
    ...
    To: toemail.join(), // it will join array value with ',' and return string
    ...
   }).then().catch();
}

An example is of join

var emails = ['one@gmail.com','two@gmail.com'];
console.log(emails.join())

log will be

one@gmail.com,two@gmail.com
Related