Filter Exchange Web Service using Exchange Query Builder for email that contains custom MAPI properties

Hi,

I have a few emails that contains custom MAPI properties that is in Microsoft Exchange Server.

I read Aspose documentation and it is using Exchange Query Builder for standard Mail Properties such as "Subject, Date and sender " to filter these email.

However, i do not see any examples that filter these emails that contain custom MAPI properties using Exchange Query Builder class as shown.

Can anyhow show me how to use Exchange Query Builder class to query Exchange Server and filter emails that contain custom MAPI properties?

Hello @Daniel12345,

Welcome to our support forum!

To filter messages by any MAPI properties, use the ExtendedProperties property. For example:

ExchangeQueryBuilder exchangeQueryBuilder = new ExchangeQueryBuilder();

// Add a condition to the query to filter items where the 'Author' extended property contains the string "Some Value"
exchangeQueryBuilder.ExtendedProperties[KnownPropertyList.Author].AsString.Contains("Some Value");

// Add another condition to the query to filter items where the 'Birthday' extended property matches today's date
exchangeQueryBuilder.ExtendedProperties[KnownPropertyList.Birthday].AsDateTime.On(DateTime.Today);

Instead of KnownPropertyList, you can use the PropertyDescriptor constructor to specify any property.

Thank you.