QueryString (QueryStringType)
The QueryString element contains a mailbox query string based on Advanced Query Syntax (AQS).
<QueryString/>
QueryStringType
Attributes and elements
The following sections describe attributes, child elements, and parent elements.
Attributes
Attribute | Description |
---|---|
ResetCache |
Indicates that the cache should be reset. |
ReturnDeletedItems |
Indicates that deleted items should be returned. |
ReturnHighlightTerms |
Indicates that highlighted terms should be returned. |
Child elements
None.
Parent elements
Element | Description |
---|---|
FindItem |
Defines a request to find items in a mailbox. The following is the XPath expression to this element: /FindItem. |
Text value
The QueryString element text value represents a mailbox query that is made by using a subset of Advanced Query Syntax (AQS). See the remarks section for information about the supported syntax options for query strings.
Remarks
In Exchange Server 2010, this element is an XML schema string type. In versions of Exchange starting with Exchange Server 2013, including Exchange Online, the type for this element is QueryStringType. This change does not break any existing clients because it adds three new optional attributes.
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 following tables list the supported search properties for each restriction type.
Word phase restriction
Property | Example | Function |
---|---|---|
from |
From:Dean From:"Dean Halstead" |
Search items sent from Dean. Search items sent from Dean Halstead. The sender must be exactly "Dean Halstead". |
to |
To:Dean |
Search items sent to Dean. |
cc |
Cc:Dean |
Search for items with Dean on the Cc line. |
bcc |
Bcc:Dean |
Search for items with Dean on the Bcc line. |
Participants |
Participants:Dean |
Search for items with Dean in the To, Cc, or Bcc fields. |
Subject |
Subject:product Subject:(product development) Subject:"product development" |
Search for items with product in the subject. Search for items with product and development in the subject. |
Body Content |
Body:progress Content:progress |
Search for items with progress in the body. |
Attachment |
Attachment:report |
Search for items with report in the attachment file name or file body. |
(property is not specified) |
Product Development |
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 an 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.
Date range restriction
Property | Example | Function |
---|---|---|
Sent |
Sent:last week Sent:01/01/2001 Sent:01/01/2001..01/15/2001 |
Search items sent last week. Search items sent on January 1st, 2001. Search items sent between January 1st, 2001 and January 15th, 2001. |
Received |
Received:today Received:01/01/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
Multiword 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.
Message type restriction
Property | Example | Function |
---|---|---|
Kind |
Kind:tasks |
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:
email
meetings
tasks
notes
docs
journals
contacts
im
The following table describes grouping logical connectors.
Grouping logical connectors
Connector | Example | Function |
---|---|---|
AND |
Subject:product AND subject:development Subject:(product AND development) Subject:(product development) |
Search items with both product and development in the subject. |
OR |
Body:project OR body:proposal Body:(project OR proposal) |
Search items with either product or development in the body. |
NOT |
NOT body:proposal Body:(NOT proposal) |
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 plus symbol (+) is equivalent to AND. The hyphen symbol (-) is equivalent to NOT. For example, body:(project - proposal) searches messages with 'project' but without 'proposal' in the body.
The query string can also contain nonindexed properties for search. If the query string contains nonindexed properties, the search might perform an Exchange search on the indexed properties and a store search on the nonindexed properties.
The schema that describes this element is located in the IIS virtual directory that hosts Exchange Web Services.
Example
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>
Element information
Code | Name |
---|---|
Namespace |
http://schemas.microsoft.com/exchange/services/2006/messages |
Schema name |
Messages schema |
Validation file |
Messages.xsd |
Can be empty |
False |