How To Find Specific Files With Matching Naming Convention from Folder And Send All Matching as One Email Attachment

Hi,

I am looking to solve an issue where I have multiple files in one folder and I need to find all the files beginning with “RWJBH_PB_BREG” as one attachment (NOT MULTIPLE). I tried using the For Each File in Folder Activity and looking for specific name, but issue is it sends multiple email (Using Send SMTP Mail) as opposed to one. Once it is done emailing I would like to archive these files under archive folder.

See the attached screenshot. All the highlighted I would like to send as part of one email attachment as opposed to multiple.

If you want to send a single attachment you’ll need to compress the files into a zip. You can do it with Compress/Zip Files activity

I suggest you use your existing iteration to copy the file to a temp folder, then, outside For each, zip the temp folder and send the email.

Hi @nirmit.kansagra

You can create an array and keep appending it in the loop with the file paths of the files whenever a match is found.

Move your archive folder and send email out of the current loop.

Outside the loop, use your send email activity and in its properties you will find attach collection option.
So, instead of attach files, you use attach a collection to upload items from your array variable there.

Then next loop to move files to archive folder.

Alternatively,
you can consider switching your first loop with directory.getfiles activity to fetch the list of the list that match the criteria.
And simply use its output to attach as a collection in send email activity.
Then only 1 loop to loop through this list to move files to archive.

Hope this helps.

Let me know if you have any further queries.

Regards
Sonali

could you share screenshot of this if possible so i can understand it better.