Download from FTP & Email send

Hello.

Can someone help cause i stuck on the following scenario.

I download multiple files via FTP and want these files to send them all together as attachments via Email.

I stuck because for example if i download 3 files via FTP then the Email sends 3 different emails with 1 attachment instead of 1 email with the 3 attachments.

Can someone shine some light?

Thank you.

1 Like

Hey @Mulen,

Welcome to the community :sparkling_heart:

Did you check this post: How i can attach two spreadsheet to one email - #4 by harshil1712? The solution provided should work for you as well :slight_smile:

If you need more help, do let us know!

Yes i checked it but i don’t have 2 workflows like this post.

My workflow is something like that:

It lists all the items in a folder. Download the items and then i want all to send them via 1 email only.

Now it sends multiple emails depending on how many files are downloaded from FTP

Here are a couple of things to try:

  • compress all the attachments together into a single zip file and then send the zip file
  • loop through all the objects in the array and merge them into a single object then send that so it will attach multiple attachments to one email

These are just theoretical. I’ll give these a try later today as a test.

Thank you.

The zip functionality thought would be good BUT in my workplace they want the attachments separated in the email. Many end-users do not know how to open a zip file in 2021…

I will really appreciate it if you can give me a solution. Thank you. I’m new to n8n and still learning.

The day you stop learning is the day you stop growing! :grinning:

I’ll spend some time later today seeing if I can figure something out for you.

1 Like

Here a basic example:

1 Like

Thank you very much.

It almost works it brings in binary tab all the 3 items but json and table are empty. It also sends 1 email now but it is empty without the attachments.

Am i doing something wrong?

@Jan beat me to the punch!

I built up a POC workflow that does exactly what you want:

You really only need the last two nodes as they prepare the files and then the second one sends them accordingly.

Let me know if it works.

2 Likes

Oh my god i can’t believe it, it works.

I can’t thank you enough!

I should really learn javascript.

Thank you a million times!

Javascript is a huge help when there isn’t a node yet that does exactly what you want.

Glad this worked for you.

@Tephlon

Can i ask something else?

As i said the above works.

I have the following scenario.

This is the table with files.

The table has a column matchkey.

I want to use this code but instead of merging all the files at once like this

I want the same functionality but they are merged depending of the matchkey column.

So the end result will be something like this


[
{
"matchkey":"mk"
"attachments": "mk0410.dat,mk0410.csv.txt,mk0410.txt"
},
{
"matchkey":"dim"
"attachments": "dim0410.csv.txt,dim0410.dat,dim0410.txt"
}
] 

I really tried to come up with a solution but i can’t make it through.

Do you have any suggestions?

Thanks.

Without knowing all of the background, I would probably start by using an IF node and get it to check the matchkey field. If it is mk, send it to the true branch and send dim to the false branch. Then, you can work with each of these branches independently.