Filter an Outlook email in Outlook that contains a specific keyword in the attachment

I am more than used to reading forums to no end but here i have to go for one of my very first post ever…
Before i start i did see previous thread on this very topic but none went to full resolution, i will link them bellow.

The process i’m trying to automate is done by the user by simply typing the keyword in the outlook search bar (ctrl + e). Automatically Outlook happen to scan the content of attachments (not the name) and that’s how the user find the relevent documents.
I am now attempting to do the same but i cannot find a suitable filter in the GetOutlookMailMessage activity.

I have attempted, in vain, the following filters:

  • attachment:
  • “@SQL=” “PR_SEARCH_ATTACHMENTS” “like SearchTerm”
    To no avail.

I am kindly refering to your help lads, you are my last hope
Thank you in advance :slight_smile:

Hi @laurent.brajkovic

Can you try like this please…I guess you need single quotes

"@SQL=""PR_SEARCH_ATTACHMENTS"" like 'SearchTerm'"

If with variable

"@SQL=""PR_SEARCH_ATTACHMENTS"" like '" + VarSearchTerm + "'"

This I am not sure directly by giving the schema it needs but can try

"@SQL="""" like 'SearchTerm'"



i have an alternate solution. Please try if that fits you.

use get outlook mailmessages activity with filer -
“@SQL= urn:schemas:httpmail:hasattachment=true”

If you want to fetch mails from new to old- then place - Int32.max

and try to fetch attachment NAme using method - CType(item.Attachments.FirstOrDefault, Attachment).Name in if condition in for each loop

(CType(item.Attachments.FirstOrDefault, Attachment).Name).Contains(“your String”)

Thank you so much for your reply (and sorry for the long delay in my response, my attention was taken to other projects while this one was frozen)

I have attempted your solutions @Anil_G but unfortunately to no avail
The first attempt appear to return no results when hardcoding a value
The second as well and as for the third i am unable to make it work at all

I am testing further and will come within the day with updates
I am welcoming other solutions attempts however ^^’

Thanks again for your time and efforts <3

1 Like

OP from the future here, to anyone looking at this headache such as i was:
Problem solved by using Get Exchange Mail Message activity and the filter:
“attachement:” + VariableKeyword