Export (0) Print
Expand All

Filtering Items

Office 2007

This topic describes the general rules for specifying properties in filters that are supported by various objects in Outlook. See the topics in the Filter Syntax section for further information on specifying conditions on properties to complete a filter.

A filter is a condition or a set of conditions that you can apply to a set of items in order to obtain a subset of items that meets the specified conditions. Outlook supports filters using the Microsoft Jet query language syntax or the DAV Searching and Locating (DASL) syntax. Note that the Jet query language syntax has the same syntax as that supported by Microsoft Jet Expression Service, hence the name Jet query language.

As an example, you can filter contact items in your Contacts folder to obtain a list of contacts residing in Canada. In this case, you will be filtering on the HomeAddressCountry property. The filter, expressed as a Jet filter, will be "[HomeAddressCountry] = 'Canada'".

Outlook provides filtering through the following entry points:

Entry PointJet Filter SupportDASL Filter Support
Application.AdvancedSearchNoYes
Folder.GetTableYesYes
Items.FindYesYes. Note that if you use the query keywords ci_phrasematch or ci_startswith in the filter, you will get an error.
Items.RestrictYesYes
Search.GetTableNoYes
Table.FindRowYesYes. Note that if you use the query keywords ci_phrasematch or ci_startswith in the filter, you will get an error.
Table.RestrictYesYes
View.FilterNoYes
Bb147579.vs_note(en-us,office.12).gif  Note
A filter must contain a query in either Jet or DASL syntax but not a mixture of both.

Property Specifiers

When specifying properties in a Jet filter or DASL filter using any of the above entry points, follow these guidelines:

Jet FilterDASL Filter
Applicable Properties Most explicit built-in and custom item-level properties; see corresponding method topic for unsupported properties.Most built-in and custom item-level properties with and without explicit string names; see corresponding method topic for unsupported properties.
Referencing Properties
  • By their explicit string names.
  • Explicit built-in properties can only be referenced by their names in English and not any other localized language.
  • Custom properties can be referenced by their names in English or a localized language.
By their namespaces.
Format of Reference
  • Enclose square brackets ('['']') around explicit string names.
  • Property names are not case-sensitive.
  • Spaces are not allowed in explicit built-in properties.
  • Spaces are allowed in custom properties.
  • All DASL queries begin with a case-sensitive prefix "@SQL=", with the exception of DASL queries for Application.AdvancedSearch.
  • Property referenced by namespace must be enclosed in double quotes.
  • Property referenced by namespace are case-sensitive.
  • If a space exists in the name of a custom property, the space must be replaced by "%20". In general, URL encoding applies the same way to characters in a DASL query as in a URL.
Error ConditionsReturns an error if a custom property in the filter is not defined, or the filter is empty, has an invalid argument, or cannot be parsed.Returns an error if a custom property in the filter is not defined, or the filter is empty, has an invalid argument, or cannot be parsed.

Filter Syntax

The syntax of a filter depends on the type of the property you are filtering on. The following topics provide further information on how to construct a filter based on a specific property type:

Filtering a Custom Field
Filtering Items Using a Boolean Comparison
Filtering Items Using a Comparison with a Keywords Property
Filtering Items Using a Date-time Comparison
Filtering Items Using a String Comparison
Filtering Items Using a Variable
Filtering Items Using an Integer Comparison
Filtering Items Using Comparison and Logical Operators
Filtering Items Using Query Keywords



Community Additions

ADD
Show:
© 2014 Microsoft