How to zip multiple images & send them via email?

I need create multiple images with a Service like Dalle2, compress them in a zip & send them via email. How to do that?

Please share your workflow

Hi @ManyQuestions, I am not quite sure what your Split In Batches node does in this example workflow (seeing you only have a single item anyway), but in general you can use this approach as the foundation.

Once you have merged multiple separate n8n items with different binary objects into a single n8n item, you can use the Compression node to get your desired ZIP file. Like so:

Hope this helps!

Hi and thanks for the answer. I tried in my main workflow. The compress node shows this result:

Can you try using an expression of {{ Object.keys($binary).join(',') }} in the “Binary Property” field of your Compression node like in the example workflow?

1 Like

Hi @MutedJam thx for the answer. When i input this expression, there comes an error:

Can you click on “Expression” rather than “Fixed” here?

1 Like

Result:

Can you take a look at the Compression node in my example workflow @ManyQuestions? You’d need to swap the values of “Binary Property” (which references your incoming data) and “Binary Property Output” (which provides the name of the result field).

1 Like

Ok that works, but when i send the zip via email, and want to open it, it says: “Archive is empty”

Unfortunately you didn’t confirm which version of n8n you are currently using. When running the below workflow including both the zipping and also the renaming from your other thread around this on [email protected] I am seeing the below result:

So I wonder if the problem is the filenames not including an extension or something else for you.

Can you try executing the full workflow (not just an individual node) from this post on your end, with valid recipient and sender data and a valid attachment value of course?

If you are still seeing the problem, can you confirm the exact version of n8n you currently have in use and share a workflow using which the problem can be reproduced? It’s fine to use the Send email node of course, but please avoid nodes such as the OpenAI requiring a paid subscription and producing non-predictable results for the purposes of reproducing such a problem.

Also, do you have the N8N_DEFAULT_BINARY_DATA_MODE environment variable set (and if so, to which value)?

1 Like

I just copied your workflow and modified it a little. It compresses the files and sends them correctly now. Thanks a lot for that.

Is it possible, to have the files named with the name of the “edit Image” node, and the number in front? Like this:

I copied the current workflow below:

Oh and my version is 0.228.2

So the “Rename files” Code node currently handles the renaming in its first line:

$input.item.binary.data.fileName = "myNewFileName_" + $runIndex + ".jpg";

This will set a new file name by combining myNewFileName_ with the current loop index (starting at 0) and appending .jpg. If instead of myNewFileName_ you want to use your existing file name, you could change this line like so:

$input.item.binary.data.fileName = $runIndex + "_" + $input.item.binary.data.fileName + ".jpg";

Let me know if this works for you :slight_smile:

1 Like

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