XML as Email Attachment

Hi again,

how i can build a xml that is generated as an attachment ?

I use this function: But when i put the data as attachment email send without attachment.

return [
  {
  json: {
    
  },
  binary: {
    data: {
      data: $node["XML1"].json["data"],
      mimeType: "application/xml",
      fileExtension: 'xml',
      fileName: "SCH.xml"
    }
  }
  }
]

Any idea ?

The property data (binary.data.data) should be Base64 encoded. https://docs.n8n.io/#/data-structure?id=data-structure

This should do it.

return [
  {
  json: {
    
  },
  binary: {
    data: {
      data: Buffer.from($node["XML1"].json["data"]).toString('base64'),
      mimeType: "application/xml",
      fileExtension: 'xml',
      fileName: "SCH.xml"
    }
  }
  }
]
1 Like

Thanks a lot @RicardoE105 that is correct. Another option would be to use the “Move Binary Data” Node.

Ricardo looks good !

1 Like