Want to stop your downloads folder from becoming an evidence locker? This quick guide shows how to use UiPath to fetch email attachments and only keep the ones you actually want. We cover picking the right mail activity, retrieving messages, applying sender and file type filters, saving files safely, and handling errors without crying.
Use Get Outlook Mail Messages for a local Outlook client. Use Get IMAP Mail Messages for server based access. Configure account settings and the folder you want to scan before proceeding. Pick the wrong activity and the robot will politely tell you it does not know what you meant.
Store the mail output in a variable called messages or something equally thrilling. Limit the number of messages to process so your first run does not turn into a weekend project. Sorting by date is handy when recent attachments matter more than receipts from 2012.
You have two good options. Use LINQ for concise filtering in a single expression or use a For Each with If checks for readability and step by step debugging.
messages.Where(Function(m) m.From.Address.ToLower.Contains("alice@company.com") AndAlso m.Attachments.Any(Function(a) a.Name.EndsWith(".pdf"))).ToList()
If LINQ makes you nervous use a For Each mail in messages then If checks on mail.From, mail.Subject or other properties. Then loop mail.Attachments and test extensions like .pdf or .xlsx to decide which attachments to save.
Drop a Save Attachments activity inside your message loop. Build the destination path with System.IO.Path.Combine and make sure the folder exists by calling System.IO.Directory.CreateDirectory(folder). If the directory does not exist UiPath will not create it on its own and you will have sad logs.
To avoid accidental overwrites add a timestamp or GUID to the file name. Example VB expression to prefix a timestamp
System.IO.Path.Combine(folder, DateTime.Now.ToString("yyyyMMddHHmmss") & "_" & attachment.Name)
Wrap your save step in a Try Catch activity and log failures with Log Message or Write Line so you can trace what went wrong. Use a test mailbox during development and add a dry run boolean that only logs matched attachments without saving them. This prevents production clutter and saves your sanity.
Follow these steps and your UiPath flow will keep only useful attachments instead of hoarding everything in sight. If the robot still misbehaves add more logging and fewer expectations. Happy automating.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.