Unable to filter successfully via Categories and Subject in "Get outlook mail message" activity

Hi,

I am attempting to filter my Outlook emails with the subject containing “XYZ” and without any category labels.

I initially used the following code: “(Not [Categories] > 0) AND (@SQL = (”“urn.schemas.httpmail.subject”" LIKE ‘%XYZ%’))". However, I encountered the following error: The condition is not valid.

Upon modifying my code to the following: “@SQL=((”“urn:schemas:httpmail:subject”" LIKE ‘%XYZ%’) AND NOT(““urn:schemas:httpmail:categories”” Like ‘%RED%’))", it seems to provide the total count of emails with the subject ‘XYZ’, even though I have an email with the subject containing “XYZ” and the category “RED” in the target folder.

I would appreciate your advice with this matter.

Thank you.

Hi @Peterx

Welcome to the community!

You’re trying to filter Outlook emails using Advanced Query Syntax (AQS). Based on your requirements, you want to filter emails with the subject containing “XYZ” and without any category labels.

Your second attempt almost got it right, but there’s a slight mistake in the syntax. Here’s the corrected version:
@SQL=((urn:schemas:httpmail:subject LIKE ‘%XYZ%’) AND NOT(urn:schemas:httpmail:categories IS NOT NULL))

Hi @Nitish_Singh ,

I attempted to use the code you provided, but it appears to only filter emails with subjects containing “XYZ”.

When I tried using the code @SQL = “NOT(”“urn:schemas:httpmail:categories”" IS NOT NULL)", it only provided the total count of the emails in the target folder.

Thank you.