Query Language
Queries look a bit like where clauses in the SQL language, however QSerachFolders can only compile expressions which are supported by the MAPI database components.
The query has the form of one or more “Fieldname operator options Constant” combined with not and and or. Sub expressions may be created with brackets.
Example
MessageClass = prefix “IPM.Contact” and (BusinessAddressCountry = "Deutschland" or BusinessAddressCountry = "Germany" or BusinessAddressPostalCode = prefix ignorecase "D")
Fieldname |
Any Outlook field or a field number expression. You may look up all existing field names in the field combo box or view the folder contents using the folder contents dialog.
Experts only:
In order to access special fields, you may use a field expression.
Field(number) |
For example, the subject can be accessed via Field(0037001E) |
UserField(name, typ) |
Accesses a standard named field, such as user defined fields in forms. |
UserField(guid, id, typ) |
For example, the field Email can be accessed via
UserField(00062004-0000-0000-C000-000000000046,8084,PT_STRING8) |
User defined fields have a numerical representation bigger then 0x80000000. The representation is different in all folders.
|
Operator |
=, <, >, <=, >= or <> |
Options |
Define how the compare should be made
Ignorecase, prefix, substring, loose or bitmask
Ignorecase |
Ignores the case of letters.
Only work with equal operator (=) |
Prefix |
Only work with equal operator (=)
Compares only the first characters of a field. For example you can find German contacts by comparing the prefix “D” in the postal code:
BusinessAddressCountry = ignroecase "Deutschland" or BusinessAddressCountry = ignroecase "Germany" or BusinessAddressPostalCode = prefix ignorecase "D" |
Substring |
Only work with equal operator (=)
Finds the constant anywhere in the string, this can be combined with ignorecase |
Loose |
Only work with equal operator (=)
Makes a loose comparison, MAPI does not exactly define what loose comparisons means. |
bitmask |
Only works with number fields of type long
Compares a value against some bits. The constant is given in the decimal representation of a bitmask. Bitmask compares are used for example to compare the message flags. For example, unread messages can be found by
MessageFlags = bitmask 2
|
|
Constant |
Any combinations of letters and numbers, a string or a time expression. Usually, the compiler knows the difference between field names and constants, but it is better to quote strings. You may write either Subject = test or Subject = “test”.
Date fields can be compared with
Now |
The time now |
Today |
Today one second after midnight |
DaysFromNow |
Some days ago. For example: DaysFromNow(5) is 5 days ago |
|
|