About EasyMorph Tutorials & Examples Web-help

Group attachments per mail

I have a folder with a large amount of pdf files, from which via mail should be sent 5 PDFs each, then the next 5 in the next mail and so on.
I have „list of files" scan the folder and create a list of all pdf files (about 250 pdfs).
My idea was to shorten the pdf name (which is always RE{NUMBER}.pdf) to just the NUMBER and make buckets of 5. Then I enumerated the groups so that I had groups of five. But I’m afraid I’m at a loss from here on. How do I manage with iterate now to send 5 pdfs by mail and then the next 5 and so on.

Hi @xlubox and welcome to the Community!

In this case, you can use the “Iterate table” action and pass the list of files into the iterated module. In each iteration simply filter the list to keep only one group (bucket of 5 files).

To learn about the “Iterate table” action, see our tutorial on iterations: EasyMorph | Iterations

If you need an example, let me know.

Hi Dmitry,
thanks for your reply. The iteration of the table is working so far. But how do I achieve that the mail has five different pdfs attached? Right now I only get one pdf per mail or if I add four more attachments in the send mail action, then I get five same attachments. Maybe an example file would actually help.


After giving it more thought, I realized that the number of file names can be different in batches, and also the “Send email” action will need parameters instead of file names anyway. This means that we can pivot the table with file names to have 5 columns with file names, and then use the regular “Iterate” action to assign 5 column names to 5 parameters instead of passing the whole table.

In the called module, we will need conditional branching for the cases when there are 1, 2, …, 5 files because in each case the number of processed (attached) files would be different.

The same project below is a bit trivialized because instead of sending files it simply outputs file names of a batch into a text file. But it provides the idea of how to process varying batches of files.

file-batches.morph (17.4 KB)

Module “Main”

Module “Output batch”

Worked out perfectly fine, thanks Dmitry!

You’re welcome!

To learn more about EasyMorph visit easymorph.com.