Get Outlook Mail Messages activity to filter emails based on content of attachment

Hi all,

I’m trying to use a “Get Outlook Mail Messages” activity to get emails based on the content of attached pdf files. As a filter I’m using:
“@SQL=”“http://schemas.microsoft.com/mapi/proptag/0x0EA5001E”" like ‘%500147801%’"

The number in betweeen the ‘%’ signs is a receipt number that only appears in the attached pdf but not in the Mail body, subject etc.
Typing the number in the Outlook search gets me the emial no problem, so I’m sure there is a way to get it to work. Using the above filter it doesn’t though.

Does anyone have any insights on how to get it to work? Maybe some tips on how the filter should look?
I found the filter expression here

Kind regards

@Felix_Rech - Just to make sure if i understand correctly…

You are trying to fetch the pdf attachments which has this # %500147801%’ on it right?? If yes please check the below post…

Hi,

thanks for the quick reply. Unfortuantely, I don’t think that is is going to help as I’m not trying to find the right attachment but rather find the right email. Ui Path Documentation on the “Get Outlook Mail Messages” activity says that the Filter property accepts JET Queries or DASL Queries but not regex

@Felix_Rech - You did not answer my question in my previous post…

what exactly you are trying to extract from the email? email has pdf and that pdf has a specific content like receipt #??

Also, this # 500147801 is used in the pdf name or on the content of the pdf??

I am using the “Get Outlook Mail Messages” activity to find the correct mail item. Later in the process i will save the attachment of the mail to a specifc folder, but that part is already working.

What I’m currently struggling with is getting the Mail as a Mailmessage object. The only way to uniquely identify the correct email is through the receipt number. As mentioned in the original post, this receipt number only appears in the content of the pdf file, not in the filename or anywhere else in the mail.

Kind regards

@prasath17 In the screenshot below you can see what I’m trying to accomplish:

I use the “Get Outlook Mail Messages” activity which outputs a List(Of MailMessage). This list then contains all Mails that fit the filter criteria. Since the mail that I’m looking for is uniquely identified by the receipt number in the mails attachment, this list will only contain 1 item when the filter is set correctly. I got this setup to work with other filters, like filtering for a specific subject, but my syntax for filtering the attachment’s content seems to be off, because I’m not getting any results after my search.

@Felix_Rech - Got it…

https://docs.microsoft.com/en-us/office/client-developer/outlook/pia/how-to-search-attachments-of-items-in-a-folder-for-an-exact-phrase

I am trying as per this page as of now no luck…when i use hasattachments it is perfectly fetching all the email which has attachment and when I use ‘attachement’ with search string…it is not working…let me research…

@prasath17 Thanks a lot! Any success in your research yet?
kimd regards

@Felix_Rech - Sorry no luck…but i will keep trying…

In outlook, if I type these I am getting the results…

And if you go View → View setting → Filter → More choices…and choose attachments it will give you the SQL code for that…

so i tried this way, but looks like there is advance filter options to select “Attachement Contains” I guess…