Cannot send e-mail from a list

Hello,

I have a json which comes with a list, please see below an example of array;

[
{
"data": [
[
{
"SomeKey1": value1,
"SomeKey2": "value2",
"e-mail": "[email protected]"
},
{
"SomeKey1": value1,
"SomeKey2": "value2",
"e-mail": "[email protected]"
},
{
"SomeKey1": value1,
"SomeKey2": "value2",
"e-mail": "[email protected]"
},]
]

I would like to use send-email node to get “e-mail” key values and use them as an expression on TO field.

But I am unable to do that.

I tried following expression;

{{$json["data"]["0"][0]["e-mail"]}}

But as you can guess it works for only 1 time. What is the suitable expression to loop it within array?

Who can help me?

Hi @No_Name, how exactly to approach this depends a bit on what you want to do. Do you want to send one email to multiple recipients? If so, the below approach would do:

This simply takes all emails and writes them into the To field separated by commas.

Hi @No_Name
Why do you have a nested array in a data array ?
It’s easier with an array of objects like below

[
  {
    "data": [
      {
        "SomeKey1": "value1",
        "SomeKey2": "value2",
        "e-mail": "[email protected]"
      },
      {
        "SomeKey1": "value1",
        "SomeKey2": "value2",
        "e-mail": "[email protected]"
      }
    ]
  }
]

{{ $json["data"][0]["email"] }} => [email protected]
{{ $json["data"][1]["email"] }} => [email protected]

Hope I help you :wink:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.