Send Mail to Multiple Addresses with REST

Hello,

I have a REST connector with MSGraph in which I am able to send emails with. However, I would like to put multiple recipients under the same email and cannot figure it out. When I create a table with the necessary data I cannot seem to use that table for the toRecipients parameter. In MSGraph, adding more emails just looks like this:

  {
    "emailAddress": {
      "address": "cc1@email.com"
    }
  },
  {
    "emailAddress": {
      "address": "cc2@email.com"
    }
  }

which is in the Model I defined for the Connector. However, I cannot seem to figure out how to input multiple emails into the same query in the Novacura connection. Any help would be appreciated, thanks.
-Andrew

Hi,

Would an option be to make a JSON string out of your email addresses, change toRecipient to be a string in your rest project, and then pass in the already well-formatted JSON?

Something like:
JSON module | Flow Help.

Unfortunately, it is not this simple. For one, it does not appear that the JSON module supports the complex structure I need for this. And secondly when I attempt to use the JSON string Novacura places slashes before every quotation mark making this solution not viable using the JSON module or without. Is there a way to use quotations in a string and remove those escape characters? Or is there a different solution?

Hey Andrew,

Basically you have 2 Options:

  1. You rebuild the Structure or even a substructure exactly as in the request in Flow tables/records. They need to match for EVERY variable name.
    If you do this you should be able to select the table in e.g. toRecipients instead of selecting Single Row. Some knowledge of Flow Script is required for this though.

Option 2:
You json.encode some of your records/table. It’s correct that the JSON.Encode function only works for simple tables/records (unfortunatly) and not more complex structures. The workaround to this is that you do this for simpler objects and either manually join them together to one big Json String that you pass on OR change the structure in the Connector. E.g. toRecipients would not be a table, but a computed value instead. If you do this you can pass on the created string one to one. That’s by far the most complex solution though, so i wouldn’t recommend it.

For the structure above which seems not Super-complex i would try to make it work with option 1.

Regards,

Johannes

Hi,

just looking at the screenshot above:
if you want to send to multiple addresses in one REST call that would basically send a mail with those addresses concatenated in “To” (“CC”,“BCC”) field with ; so something like: cc1@email.com;cc2@email.com

So before you get into the REST machine step you could run that table through script with join function and ; separator and then just use that single variable?

Hope this helps

B R
Ivan

In your “ToRecipients” you have selected Single Row. Just change that to a table and pass in your table of To people and that should be it.