Filter an Outlook email in outlook that contains a specific word in the attachment

Hello,

In Outlook I have to search through an email folder in shared mailbox containing close to 5000 emails along with new emails are stored every day. Every email have an xlsx attachment. I have to search for a term (number or String) in that dump of emails and find that email having that search term in the attachment. Manually if enter the search string in "search current mailbox bar " it takes 3-4 sec to give the email that has that string in the attachment.

How can I do that with Uipath with getoutlook mail activity? What should be the filter condition in Getoutlook mail activity. If i give just the string in the filter field it is throwing invalid condition.

I cant download each and every email attachment and loop through those thousands of excels to search for that string.

Thanks in advance
best regards
Raghu

Create a rule in Outlook with Header contains “file name” move it to your custom folder, and for Get outlook mails Activities Input that folder name to read Emails.

its not the header. String that has to be searched in outlook mail folder will be received from a different input file. So string is not constant here. That dynamic string value has to be searched through 5000 odd emails and get that attachment from the email that has this string. Body of the email is not required here.

use Following in your ForEach, this would work only after pulling out emails. If filtering while fetching itself is something we need to look

mls-> your Get outlook mailmessage output
mls.AsEnumerable().Where(Function(msg) (msg.Attachments.AsEnumerable().Where(Function(str) str.Name.ToString.Contains("inputString")).ToArray().Count>0))

I am VERY interested in this answer but do not understand how to input the above mentionned in a For Each. Where am i supposed to input that string of code and how ?
Thank you kindly in advance :slight_smile:

Hello @laurent.brajkovic :slight_smile:

Welcome in UiPath community! :grinning:

This line of code is called LINQ query and in UiPath Studio we can call this code simply in the Assign activity. On the left side, we place a variable that will store the result of the query.

Thank you so much for this insight
Here is how my naive self understood the implementation
While i’m fully aware of doing it wrong, and knowing you are not the author of the LINQ string, do you have any idea how it was meant to be used/implemented ?
image