The goal
I’m trying to iterate over an unknown number of files, download each file’s binary data, and include all of the files as attachments in the Send Email node.
My approach
In my case, the “get deal info” node returns n file URLs so that each one can be referenced as $node["get deal info"]["data"]["deal"]["statements"]["edges"][*n*]["node"]["url"]
.
The “iterate over files” code node outputs each URL separately.
Then a “loop over items” node sends each URL to the “download file” node, which makes a GET request and puts each file’s binary data in a field named data{{ $node["loop over items"]["context"]["currentRunIndex"] }}
.
The “aggregate files” code node returns the binary data names as a comma-separated string.
And finally, the “send email” node’s Attachments expression is {{ $('aggregate files').item.json["attachments"] }}
.
The problem
An email is being sent out, but without any attachments. The comma-separated string “data0,data1,data2” doesn’t seem to reference any binary data. How do I properly aggregate the binary data and attach all the files in one email?
My workflow
Last node’s output
[
{
"accepted": [
"[email protected]"
],
"rejected": [],
"ehlo": [
"SIZE 35882577",
"8BITMIME",
"AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH",
"ENHANCEDSTATUSCODES",
"PIPELINING",
"CHUNKING",
"SMTPUTF8"
],
"envelopeTime": 149,
"messageTime": 401,
"messageSize": 285,
"response": "250 2.0.0 OK 1712679531 f8-20020a05600c4e8800b00415dfa709dasm17903532wmq.15 - gsmtp",
"envelope": {
"from": "[email protected]",
"to": [
"[email protected]"
]
},
"messageId": "<[email protected]>"
}
]
My n8n setup
- n8n version: 1.29.1
- Database (default: SQLite): default
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
- Operating system: Mac OS, Arc browser