Email multiple files (1 file per email)

I am hoping someone can tell me an efficient way to tackle my issue.

  1. Open local folder (contains 50+ files and subfolders)
  2. Email files that are file type: pdf. (1 file attachment per email)
  3. Before emailing the next pdf, move the processed file (in step 2) to a subfolder - “Emailed Pdfs” [this step is meant to be a check to ensure all pdfs were successfully emailed]

Thank You for your help!

1 Like

Hi Hnaseem,

I think there are some good UiPath components you can leverage to do this.

First, in your “Snippets” menu, you should have the file “For Each File In Folder.xaml”. This workflow iterates over each file in an indicated folder, you can either build on top of the snippet or use it as a model to build something similar.

Having this component, you need to write some logic inside the for loop. For each file you could start by checking that it is a PDF by looking at the filename. Then, you could send the file with one of our “Send Mail” activities (there are a few, you need to choose one based on your email provider). Lastly, you can use a “Move File” Activity to move the file after you’ve emailed it. Writing this all in the “for” loop will apply it to each file one at a time.

Hope this helps!

Best,

Evan

1 Like

Hi @hnaseem,

In addition to @Evan_Bruns comments,
In for each file in folder use the code

directory.getfiles(your folder path, “*.PDF”, searchoptions.alldirectoryies)

The above snippets will get all the PDF files only and will search in all subfolders as well…

1 Like

Great! It worked. Thank you.

Good to hear.

if it is working. mark this is as solution.