次の方法で共有


QueryString

Last modified: October 21, 2009

Applies to: Exchange Server 2007 | Exchange Server 2010

The QueryString element contains a mailbox query string based on Advanced Query Syntax (AQS).

<QueryString/>

string

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

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 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.

Remarks

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.

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 carbon copy line.

bcc

Bcc:Dean

Search for items with Dean on the blind carbon copy 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 of 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 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

  • 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.

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 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.

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="https://schemas.microsoft.com/exchange/services/2006/messages" 
               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
               xmlns:soap="https://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="https://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo MajorVersion="14" 
                         MinorVersion="0" 
                         MajorBuildNumber="639" 
                         MinorBuildNumber="20" 
                         Version="Exchange2010" 
                         xmlns:h="https://schemas.microsoft.com/exchange/services/2006/types" 
                         xmlns="https://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="https://schemas.microsoft.com/exchange/services/2006/messages" 
                        xmlns:t="https://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

Namespace

https://schemas.microsoft.com/exchange/services/2006/messages

Schema name

Messages schema

Validation file

Messages.xsd

Can be empty

False

See Also

Other Resources