The binary data is shortened here but is correct. Here is the main part of the function which generates it:
// read the XML file content
const fileContent = fs.readFileSync(this.filePath, "utf-8");
// get the binary data
const binaryData = Buffer.from(fileContent, "utf-8");
// convert the binary data to Base64
const base64Encoded = binaryData.toString('base64');
// return as object in the n8n format
return {
data: base64Encoded, // Base64-encoded string
mimeType: 'application/xml', // Set MIME type (e.g. application/xml for XML files)
fileExtension: 'xml', // File extension (e.g. xml)
fileName: 'test.xml', // File name you want to appear
};
In the field “Attachments” in the Send Mail node I put only the name. I tried “data”, “binary” and “binaryData”, but nothing works. The email arrives every time without an attachment.
Used version of n8n: 1.83.2 (self hosted in a Docker container)
I hope somebody can help me what I do wrong. If you need more information, please let me know.