Filtering a Custom FieldFiltering a Custom Field

You can specify custom properties in filters using Microsoft Jet syntax or DAV Searching and Locating (DASL) syntax.You can specify custom properties in filters using Microsoft Jet syntax or DAV Searching and Locating (DASL) syntax. The custom properties must be defined in the folder where you are applying the filter.The custom properties must be defined in the folder where you are applying the filter. If the custom properties are only defined in the item, the search will fail.If the custom properties are only defined in the item, the search will fail.

Jet QueriesJet Queries

Custom properties can contain spaces in the property name.Custom properties can contain spaces in the property name. In a Jet query, as in all property name references, simply enclose the custom property name in square brackets.In a Jet query, as in all property name references, simply enclose the custom property name in square brackets. For example, the following Jet query retrieves all contacts where the custom property named "Preferred Gift" is exactly "Diamonds".For example, the following Jet query retrieves all contacts where the custom property named "Preferred Gift" is exactly "Diamonds". For the query to succeed, the custom property named "Preferred Gift" has been defined in the folder that contains the custom contact items: For the query to succeed, the custom property named "Preferred Gift" has been defined in the folder that contains the custom contact items:

criteria = "[Preferred Gift] = 'Diamonds'"

DASL QueriesDASL Queries

In a DASL query, if the name of a custom property contains spaces, you must apply Uniform Resource Locator (URL) encoding to each space character and replace the space with "%20".In a DASL query, if the name of a custom property contains spaces, you must apply Uniform Resource Locator (URL) encoding to each space character and replace the space with "%20". In general, URL encoding applies the same way to characters in a DASL query as in a URL.In general, URL encoding applies the same way to characters in a DASL query as in a URL.

When you construct a DASL query for a custom property, you must use the namespace GUID for Outlook custom properties in the following format:When you construct a DASL query for a custom property, you must use the namespace GUID for Outlook custom properties in the following format:

http://schemas.microsoft.com/mapi/string/{GUID}/PropertyName

onde {GUID} é a seguinte GUID:where {GUID} is the following GUID:

{00020329-0000-0000-C000-000000000046}{00020329-0000-0000-C000-000000000046}

Filtering Custom Properties Referenced by the MAPI String NamespaceFiltering Custom Properties Referenced by the MAPI String Namespace

Se a propriedade personalizada que você está filtrando para não existir na coleção UserDefinedProperties da pasta, e se você está fazendo referência a propriedade personalizada por MAPI namespace da cadeia de caracteres, então você deve acrescentar explicitamente um especificador de tipo para o representação de namespace da propriedade personalizada.If the custom property you are filtering for does not exist in the UserDefinedProperties collection for the folder, and if you are referencing the custom property by the MAPI string namespace, then you must explicitly append a type specifier to the namespace representation of the custom property. Note that you need to specify the type only when applying a DASL filter to search and filter entry points in the Items collection and the Table object, and to the Application.AdvancedSearch method.Note that you need to specify the type only when applying a DASL filter to search and filter entry points in the Items collection and the Table object, and to the Application.AdvancedSearch method.

Observação O especificador de tipo hexagonal deve ser do 0000HHHH formulário com apenas 8 dígitos em vez de 9.Note The hexagonal type specifier must be of the form 0000HHHH with only 8 digits as opposed to 9. Para obter mais informações sobre os especificadores de tipo hexagonal (HHHH) para vários tipos MAPI, consulte Tipos de propriedade.For more information on the hexagonal type specifiers (HHHH) for various MAPI types, see Property Types.

Por exemplo, se você quiser usar Restrict para pesquisar o Unicode personalizado chamada "MyProperty" e essa propriedade de propriedade de cadeia de caracteres não existir na coleção UserDefinedProperties da pasta, você deve acrescentar o tipo de cadeia de caracteres Unicode especificador, 0000001f, para a representação da propriedade no namespace MAPI cadeia de caracteres:For example, if you want to use Items.Restrict to search for the custom Unicode string property named "MyProperty" and this property does not exist in the UserDefinedProperties collection for the folder, you must append the Unicode string type specifier, 0000001f, to the representation of the property in the MAPI string namespace:

criteria = "@SQL=" & Chr$(34) & "http://schemas.microsoft.com/mapi/string/" _ 
& "{00020329-0000-0000-C000-000000000046}/MyProperty"_ 
& "/0000001f" & Chr(34) & " = '12-74440'"