Cant send Email with multiple attachments :(

Good evening,

I am trying to create a node where I can send attachments via email. I have 2 attachments in one system (Ninox). However 2 emails are generated in Outlook. I would like to have one email with both attachments and not 2 emails with one attachment each.

I hope someone can help me here.

Thanks a lot!

Please share the workflow

Share the output returned by the last node


Information on your n8n setup

  • n8n version: 0.211.2
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker
    !

Hi @Robert and welcome to the community. Your workflow is sending two mails because all nodes run once for each item by default. If you want to send only one email with both attachments you can concatenate your items using the Item Lists node, like in my example below:

Hope that helps

Sadly does the Item Lists not currently not operate with binary data. For that reason is the solution actually a little bit more complicated right now and requires the Code-Node and an Expression on the GMail-Node. Hope we are able to add support for binary data to the Item Lists node soon.

Hey Niklas and Jan,

thanks a lot for your help. Unfortunately I was not successful with the implementation of your suggestions.

The output is 1 item, but this is empty.

Ah yes, that is expected. My solution expected that your binary properties are named as by default “data”.

If it has totally random names then the Code would have to look like this:

let counter = 0;
return [
  {
    json: {},
    binary: $input.all().reduce((acc, item) => { 
      Object.keys(item.binary).forEach(key => {
        acc['data'+(counter++)] = item.binary[key];      
      })
      return acc;
    }, {})
  }
]

Hello Jan,

you code works! Great! Thanks a lot! Now there is just
the problem that no binary data is found in the output (see screenshot)

Ah sorry, did not see that you were using Outlook as the other example workflow used Gmail.

The problem there is that the Outlook node did not get updated yet and it currently does not support sending multiple attachments by comma separating them. It expects each of them in a separate field. For that reason, does it instead of looking for the binary properties data0 and data1 look for one that is called data0,data1 which does obviously not exist.

Can you also use Gmail or the Send Email node and configure it to connect to your Outlook account?

Hi Jan,

I tried the SendMail Node, but it seems that it is not fully compatible with Outlook, because it has the wrong SSL version!?

have removed the email addresses after testing, so they are missing on the screenshot :wink:

Hi @Robert, this might be a problem with your SMTP credentials. Perhaps you want to disable the SSL/TLS option in your credentials?

image

This would mean n8n uses STARTTLS instead and also matches the example configuration we have tested when user management was first rolled out.

2 Likes

Hi Jan,
I have a similar problem, I want to send multiple attachments in one email.

Thanks to your instructions, this works, but the Mail node cannot work with the result.
Do you have another tip for me?

Hi @micha1, you probably want to use an expression like {{ Object.keys($binary).join(",") }} as the Send Email node is expecting a comma separated list of binary properties, not the full binary data:

grafik

1 Like

Thanks it works perfectly

2 Likes

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