Send email attachment to multiple recipients

Hi,

I’m new to n8n and there must be something I’m missing. This workflow is simple and I’ve followed what I can find in the doc’s and in the community posts, but the workflow is not working as it should.

The requirement is to send an email with an attachment (or multiple attachments) to multiple email recipients.

The workflow executes without an errors and sends emails to each of the recipients but does not attach the file.

good day @OptimaBSC
This usually happens when the email node can’t find the file in the item it receives. In n8n, attachments only work if the file is still present as binary data and the value in the Attachments field matches that binary property name exactly. So I’d first check the Send Email node input and confirm the file is still there, because the Code node before it may be dropping the binary data. If the binary property name is different from what you entered in Attachments, the email will send normally but without the file.

Hi @tamy.santos

Thanks for the reply.

The email node inputs does show the file.

If the code node is removed and the email node recipient is fixed to one recipient only, then the email is sent with the attachment.

The purpose of the code node is to define a list of email recipients, which can be inserted in the email node using an expression to send emails to each recipient with the file attached.

Any suggestions how this can be achieved?

The file is still present

@OptimaBSC

What I’d try is either sending one email with all recipients in a comma-separated list in the To Email field, or having the Code node return one item per recipient while copying the same binary data onto each item. The main thing is that each email the node sends needs to stay tied to the item that contains the attachment, so if your code is only building the recipient list but changing the item structure, that can cause this kind of behavior even when the file still appears upstream.

@tamy.santos

Ok, I (think) I understand what you are getting at. So the ‘Send an Email’ node must come after the ‘Convert to File’ node, right? Something like this:

How then can the list of email recipients be defined (e.g. pulling from an external source) and then used to send one single email to all recipients or send multiple individual emails to each recipient? The idea is that the email recipient list could be generated on for example a departmental list of employees (e.g. sales department) from an address directory.

@OptimaBSC

You don’t have to put Send Email immediately after Convert to File, but the key is that the item reaching Send Email must still contain the file in its binary data. So yes, you can fetch the recipients from another source first, but then you need to combine that recipient data with the item that holds the attachment. From there, you have two clean options: either keep everything as one item and send one email with all recipients joined in the To Email field, or create one item per recipient while copying the same binary file onto each item, so n8n can send one email per person with the attachment included each time. The important part is not the exact node order, but making sure the recipient item and the attachment binary stay together before the email node runs.

@tamy.santos

Thank you, got it working. Much appreciate the help.

Happy to help! :blush: