Need to add a filter in the Get Outlook Mail Messages activity where it filters sender email and Subject contains

I need to add a filter in the Get Outlook Mail Messages activity where it filters a specific sender email and a particular text contains in the subject. I have tried something like below but it does not work.

“@SQL=”“urn:schemas:httpmail:subject”" like ‘%my text%’ AND [SenderEmailAddress]=‘test@gmail.com’"

Note - I know we can do this by reading the whole mailbox and checking each email’s sender and subject in a loop with an IF. But I am looking for a better option as mentioned above if possible.

Hi @Tharusha_Jayadeera

Please try this filter option & let us know if it works:

"[SenderEmailAddress] = 'test@gmail.com' AND [Subject] LIKE '%my text%'"

Edit: You can try it like this as well-

"@SQL=(""urn:schemas:httpmail:subject"" like '%my text%') AND ([SenderEmailAddress] = 'test@gmail.com')"

Hope this helps,
Best Regards.

1 Like

Hi @arjunshenoy,

Thanks for the quick reply.

The 1st one gives the below error.
“[SenderEmailAddress] = ‘test@gmail.com’ AND [Subject] LIKE ‘%test text%’”
Condition is not valid

The 2nd one gives the below error.
“@SQL=(”“urn:schemas:httpmail:subject”" like ‘%test text%’) AND ([SenderEmailAddress] = ‘test@gmail.com’)"
Cannot parse condition. Error at “@SQL=(((“urn:schemas:httpmail:subject” l…”.

@Tharusha_Jayadeera

You cannot combine jet and dasl query…so please try this

"@SQL=""urn:schemas:httpmail:subject"" like '%my text%' and ""urn:schemas:httpmail:fromemail"" like '%Emailaddres%'"

Hope this helps

Cheers

1 Like

Hi @Anil_G,

Thanks for the reply.

I think the second condition for the email sender address needs to be corrected in your query. But I got your point regarding the dasl and tried it below.

“@SQL=”“urn:schemas:httpmail:fromemail”" = ‘test@gmail.com’ AND ““urn:schemas:httpmail:subject”” LIKE ‘%test text%’"

Now there is no exception. But it does not return anything when there are emails that exist.

@Tharusha_Jayadeera

please try using like(instead of equals) for fromemail as well and include percentage and check

cheers

1 Like

Hi @Tharusha_Jayadeera

Can you try this-

"@SQL=""urn:schemas:httpmail:senderemailaddress"" LIKE '%test@gmail.com%' AND ""urn:schemas:httpmail:subject"" LIKE '%my text%'"

Thanks!!

1 Like

Hi @Anil_G , @Nitya1,

Thank you. I’ve tried both ways. But still, it does not return anything when there are emails that exist.

(It is working only with the subject filter)

Hi @Tharusha_Jayadeera ,

Please have you been able to find any solution to this, Im stuck with the same issue also, works for the subject, but doesnt work for the email sender