The QueryString element contains a mailbox query string based on Advanced Query Syntax (AQS).
The following sections describe attributes, child elements, and parent elements.
Defines a request to find items in a mailbox.
The following is the XPath expression to this element: /FindItem.
The QueryString text value represents a mailbox query by using a subset of Advanced Query Syntax (AQS). See the remarks section for information about the supported syntax options for query strings.
The QueryString element excludes the use of EWS restrictions. AQS in EWS supports three types of restrictions: word phase restriction, date range restriction and message type restriction. The tables below list the supported search properties for each restriction type.
Search items sent from Dean.
Search items sent from Dean Halstead. The sender must be exactly “Dean Halstead”
Search items sent to Dean.
Search for items with Dean on the carbon copy line.
Search for items with Dean on the blind carbon copy line.
Search for items with Dean in the To, Cc, or Bcc fields.
Search for items with product in the subject.
Search for items with product and development in the subject.
Search for items with progress in the body.
Search for items with report in the attachment file name of file body.
(property is not specified)
Search for items that contain both product and development in all word phase properties.
Word phase restriction match is always case insensitive. Word phase restriction supports two match types: prefix match or exact match. Prefix match is the default match behavior. If you want exact match, use double quotes. For example, subject:”product” matches ‘product’ but not ‘production’ in the subject. Multiple words in double quotes restrict both word phases and their order. For example “win product” matches only ‘win product’, not ‘win95 product’ or ‘product of win’. You can use asterisk ‘*’ to define a prefix match with order restricted. For example “win product”* matches ‘win95 product’, ‘windows production line’ but not ‘windows new product’ or‘product of win’. You can search all messages sent from or to a domain. For example: from:”@hotmail.com” returns all messages sent from hotmail.com.
The following table describes date range restrictions.
Search items sent last week.
Search items sent on January 1st, 2001.
Search items sent between January 1st 2001 and January 15th 2001.
Search items received today.
Search items received on January 1st, 2001.
The two dots ‘..’ is a range operator. It can be used to define a range with a start and an end date. To specify a date, you can use relative dates. The following relative dates are supported:
Relative dates: Today, tomorrow, yesterday
Multi-word relative dates: This week, next month, last week, past month, or coming year.
Days: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
January, February, March, April, May, June, July, August, September, October, November, December
The following table describes message type restrictions.
Search all task items.
AQS in EWS uses the Kind property to specify the message type. The Kind property can be used with the following item types:
The following table describes grouping logical connectors.
Subject:product AND subject:development
Subject:(product AND development)
Search items with both product and development in the subject.
Body:project OR body:proposal
Body:(project OR proposal)
Search items with either product or development in the body.
Search messages without proposal in the body.
AND is always the default connector. For example, subject:project AND body:proposal is the same as subject:project body:proposal. Logical connectors are case sensitive. For example, body:(project Or proposal) searches messages with ‘project’, ‘or’ and ‘proposal’ in the body instead of ‘project’ or ‘proposal’. The symbol ‘+’ is equivalent to AND. Symbol ‘-‘ is equivalent to NOT. For example: body:(project – proposal) search messages with ‘project’ but without ‘proposal’ in the body.
The query string can also contain non-indexed properties for search. If the query string contains non-indexed properties, the search may perform an Exchange search upon the indexed properties and a store search upon the non-indexed properties.
The schema that describes this element is located in the EWS virtual directory of the computer that is running Microsoft Exchange Server 2010 that has the Client Access server role installed.
The following example shows a request to search for messages in the inbox with "Autodiscover" in the subject.
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <t:RequestServerVersion Version="Exchange2010" /> </soap:Header> <soap:Body> <m:FindItem Traversal="Shallow"> <m:ItemShape> <t:BaseShape>IdOnly</t:BaseShape> <t:AdditionalProperties> <t:FieldURI FieldURI="item:Subject" /> </t:AdditionalProperties> </m:ItemShape> <m:IndexedPageItemView MaxEntriesReturned="1" Offset="0" BasePoint="Beginning" /> <m:ParentFolderIds> <t:DistinguishedFolderId Id="inbox" /> </m:ParentFolderIds> <m:QueryString>subject:Autodiscover</m:QueryString> </m:FindItem> </soap:Body> </soap:Envelope>
The following example shows a successful response to the request.
<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="639" MinorBuildNumber="20" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> </s:Header> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <m:ResponseMessages> <m:FindItemResponseMessage ResponseClass="Success"> <m:ResponseCode>NoError</m:ResponseCode> <m:RootFolder IndexedPagingOffset="1" TotalItemsInView="5" IncludesLastItemInRange="false"> <t:Items> <t:Message> <t:ItemId Id="AAMkADEzOTExYjJkLTYx" ChangeKey="CQAAABY" /> <t:Subject>How to use Autodiscover</t:Subject> </t:Message> </t:Items> </m:RootFolder> </m:FindItemResponseMessage> </m:ResponseMessages> </m:FindItemResponse> </s:Body> </s:Envelope>