Sendgrid Dynamic To or CC - Input as List of Recipients

When I use the Sendgrid Node, I sometimes dont know the recipients until Runtime.
Those recipients I retrieve from a global JSON array.
I then loop through that array and send one email to each email address in the array.

Is there a way I can just plug the array into the Sendgrid Node’s To or CC field and it would add them as additional CC or TO recipients?

How can I programatically send one email to multiple TO or CC recipients?

image

In the image above, if I wanted TO to be…

jane@doe.com, john@doe.com, scott@santa.com, turkey@giving.com,

Would I need to do string concatenation and plug it in with a single template variable that way?

Hey @Kyle_Stokes2,

I did some testing and was able to send emails to 3 addresses by putting an array of emails on the payload, and then using {{data.emails}} in the “To” field.

My email field looks like:

{
    "emails": [
        "success@losant.com",
        "hello@losant.com",
        "support@losant.com"
    ]
}

And was sent via a Virtual Button.

Please let me know if this works for you.

Thank you,
Heath

1 Like

Yes, this is exactly what I needed. Thank you. Any chance to add to the documentation here: https://docs.losant.com/workflows/outputs/sendgrid/#recipient-addresses ?

It was not immediately apparent to me that I could pass it an array.