Merge Two Files in First Row for One Mail


I’m able to merge my files in Code node;

See my last topic about merging files from Split in Batches : How to merge Files from Split-in-Batches Node into One to send in a Mail? - #3 by onurbolaca

const allData = []

let counter = 0;
do {
  try {
    const items = $items("Download Files", 0, counter);
    allData.push.apply(allData, items);
  } catch (error) {
    return allData;  

} while(true);

I cannot send them in one mail though, it sends two mails for each file;

It comes like this;

Drive Node

Merge Data JS Node

I think I just need to edit the code and combine all the files in the first index of array,
It should basically look like this;

Then I will collect it like this;


Do you have any idea about how to send them in one mail?

Information on your n8n setup

  • n8n version:Version 0.219.0
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker):
  • Operating system:Linux

Here is how you can do it;

const result = { binary: {} };
const resultArr = [];

let counter = 0;
do {
  try {
    const items = $items("Download Files", 0, counter);

    // Add each item to the binary object of the result object
    items.forEach((item, index) => {
      result.binary[`fileName${counter + index}`] =;

  } catch (error) {

     return resultArr;

  counter += items.length;
} while (true);

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