'How to search for the name of the UserProperty in Outlook.MailItems, not their value

BACKGROUND:

Currently I am searching Outlook.MailItems where their UserProperty (here, "IsProcessed") is equal to its propertyValue (here, true or false).

string propertyValue = "true";
string filter = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/IsProcessed LIKE \'%" + propertyValue + "%\'";

I am using this filter string in advancedSearch link to doc

PROBLEM STATEMENT:

My usecase is to search if these mailItems have any UserProperty assigned where name of UserProperty = "IsProcessed".

Is there any way to do so using similar DASL filter string?

Thanks.



Solution 1:[1]

No, you need to know the GUID. All user properties in OOM use the GUID of {00020329-0000-0000-C000-000000000046} (which is PS_PUBLIC_STRINGS).

To see the DASL name of a property, take a look at existing messages with OutlookSpy (I am its author - select the message, click IMessage button) - when you select a named property (bolded) OutlookSpy will show its GUID, id, and the DASL name.

Solution 2:[2]

You can use the following criteria to get items with a user property set up:

string filter = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/IsProcessed IS NOT NULL";

or get items with a user property not set:

string filter = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/IsProcessed IS NULL";

See Is Null operator in search strings.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Eugene Astafiev