Hello everyone! New UiPath intern here looking for a bit of assistance.
I need to loop through all items in a List of MailMessages and filter only the items that contain attachments of only .xlsx or .csv file types.
For example:
Email1 attachments: file.xlsx, file.csv → KEEP MAIL OBJECT IN LIST
Email2 attachments: file.csv → KEEP MAIL OBJECT IN LIST
Email3 attachments: file.xlsx, file.csv, file.jpg → REMOVE FROM LIST (contains .jpg file)
Email4 attachments: file.txt → REMOVE FROM LIST (does not contain .xlsx or .csv)
Any file type could be in these emails (.jpg, .txt, .mp3, etc.), but I only want to keep the emails with exclusively .xlsx and/or .csv
Please let me know if I can further clarify this question. Thanks!
Thanks for your response! I would like to use the Save Attachments activity after I have filtered through the emails. Emails that contain file types other than .xlsx or .csv need to be removed from the list of MailMessages before I can save attachments.
For example:
Email1 attachments: file.xlsx, file.csv → KEEP MAIL OBJECT IN LIST
Email2 attachments: file.csv → KEEP MAIL OBJECT IN LIST
Email3 attachments: file.xlsx, file.csv, file.jpg → REMOVE FROM LIST (contains .jpg file)
Email4 attachments: file.txt → REMOVE FROM LIST (does not contain .xlsx or .csv)
I need to iterate through the list of emails from the Get Outlook Mail Messages activity and remove Mail objects that contain file types other than .xlsx or .csv. I just can’t figure out how to build an activity + conditional statement that will fulfill this filter.
After I have filtered the emails in the List, I will then use the Save Attachments only for the remaining emails, Email1 and Email2.
To iterate through the list you could try using a for each activity.
To remove the unwanted files you’d have to use a write line inside the for each first just to see the item output. Based on the output you may need to use more than one.
Thanks for your response. Inside the for each activity I would like to remove unwanted Mail objects that contain attachments that are not .xlsx or .csv.
Mail1: .xlsx, .csv → GOOD EMAIL (keep in list)
Mail2: xlsx, .csv, .zip → BAD EMAIL (remove from list)
Emails that contain file types other than .xlsx or .csv need to be processed by a human. Emails containing file types of only .xlsx or .csv are good for robotic automation.
Hi @Vineet_Joshi, thanks for your response. Yes, that suggestion from @Edwin_Barahona will definitely work for my needs. However, I would like to filter Mail objects in the List before I use **Save Attachments. Please see my original post example for the precise filter that I need. Thank you again for responding.