Workflow with attachment sends two mails instead of one

I use the cloud version of n8n. Ihave a workflow for sending an email which contains a

  • plain text body with a customer number and a
  • binary attachment (PDF file)

One ingoing node serves the binary, the other the JSON with the customer number:

Now two mails are being sent. One with attachment and one without attachment.
I only want to send one email.

Is it because I have two input nodes? IMHO the merge node doesn’t help here, as it only merges two JSONs, but not a binary and a JSON?!

How can I force n8n to only send one email instead of two?

Yes, that is expected behavior and is supposed to work that way. After all, do you send two totally different items to the Send Email Node, and so it will execute 2x.

If you want that it executes only once, you have to make sure only to send one item to the node. You can do that, by combining the two items into one with the help of the Merge-Node. The settings to achieve what you want would be:

  • Mode: Combine
  • Combination Mode: Merge By Position

The Merge-Node will then combine the data it receives from both inputs into one item. If you connect the Send Email node afterward it will do what you want.

Be aware that, in most cases, you do not want to connect more than one connection to one input. It is normally just required if you:

  • Build a loop
  • You have items from different branches which should process the data the same way moving forward

Thanks @jan for your fast weekend response and your explanations.

I tried the merge node before, but didn’t realize, that I have to use the “Merge by position” mode. I thought, the merge node was simply not able to merge a binary and a JSON.

It works now! Thanks!

BTW I’m really amazed of the usability of n8n. I had so many situations, where I thought, it would be really nice, if I would now have the option to do X and then discovered, there’s a button or option for exactly that. :slight_smile:

You are welcome!

Really great to hear that n8n is useful for you and turned never out to be a blocker. That is def. one of our goals to be the most powerful and versatile tool out there.

Have fun!

1 Like

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