Create attachments from single files for email module

Hello everyone!

I am currently working on an application form which sends the uploaded files received from a webhook as email attachments.

The webhook provides the Individual files, which are optional - this means the attachments can have more or less files. First I use this amazing trick to conditionally download the files (see image below) Then I save both “data” and “file_name” for each file in a separate variable. So for example I have “file1” for data and “file1_name” for the name.

Now, I need to combine the data and name into a single attachment and repeat this process for every file to create an attachment-array the email module can process.

So either I create an empty structure at the beginning and add every attachment to it. Or I create an array and filter out all NULL values.

Does anyone have an idea how I can achieve this? I already tried aggregators and played around way too long with every possible combination of “get” and “set” variables.

All the best
David