i want to send many attechments as one Email, but i habe a error
It looks like your topic is missing some important information. Could you provide the following if applicable.
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system:
You’ll find that you’ll get more responses if you post a smaller workfow that shows your issue. Right now we have no idea where to look ![]()
Hi,
i have Problem with Binary. I want to send my message Attechment as array. Because i want to send all my Attechment with one message.
@nabies Are you trying to send attachments from multiple workflow items or multiple files from a single item?
I am trying to send multiple attestations/files from one email
To send multiple attachments in one email:
- For files from different workflow items:
- Add a “Split In Batches” node
- Set “Batch Size” to the number of items
- Connect to an “Email Send” node
- In Email node, select “Send attachment” and use expression:
{{$json["binary"]}}
- If files are already in an array in one item:
- Use a “Function” node to format them properly:
// Assuming files are in $json.files array
const newItem = { json: {}, binary: {} };
items[0].json.files.forEach((file, i) => {
newItem.binary[`attachment${i}`] = file;
});
return newItem;
The Email Send node will automatically include all binary properties as attachments.
const newItem = { json: {}, binary: {} };
if (Array.isArray(items[0]?.json?.files)) {
items[0].json.files.forEach((file, i) => {
newItem.binary[attachment${i}] = file;
});
} else {
console.warn(“items[0].json.files is not an array or is undefined”);
}
return newItem;
this code works, but the result is like this: This is an item, but it’s empty.
the code is failing because items.json.files likely doesn’t contain properly formatted binary data
Try this code:
// Check binary data format and structure it properly
const newItem = { json: {}, binary: {} };
// If files are in binary properties spread across items
if (items.some(item => item.binary)) {
items.forEach((item, index) => {
Object.keys(item.binary).forEach(key => {
newItem.binary[`attachment${index}_${key}`] = item.binary[key];
});
});
}
// If files are in json.files but need proper binary structure
else if (Array.isArray(items[0]?.json?.files)) {
items[0].json.files.forEach((file, i) => {
// Make sure file has proper binary format
if (typeof file === 'object' && file.data) {
newItem.binary[`attachment${i}`] = file;
}
});
// Also copy other json properties if needed
newItem.json = {...items[0].json};
delete newItem.json.files;
}
return newItem;
Since the hasAttachments variable is set to true, I believe the attachment was successful. The referenced name in the API might be different, so please check for that.
@nabies Do i have any updates on this. I tried to setup my own workflow of this and it seems working (tried with SMTP and Gmail) the attachments are getting added.
bun i need it for outlook, i have same error
@nabies What you are having now is Variable Reference error, The initial part of this question seems to be solved, we can easily solve it, but further discussing it here would dilute this problems solution, and we might be marked for spam, I kindly ask of you to create a new question for this.
Also add the whole response of Microsoft outlook on that question so we can discuss it.
Could you paste the Whole json file of your workflow in here in </>


