4

我正在尝试使用 Exchange EWS 2010 在对话中查找项目,无论它们位于哪个文件夹中。而且我不想在单个文件夹中获取所有对话 ID 的列表。我想在对话的基础上进行查询。

我在 Android 上执行此操作,并且一直在为其他 EWS 请求发送 XML 肥皂请求。

我的问题是这样的:

鉴于它的 ConversationId,应如何格式化 XML 以在单个对话中检索项目?

我尝试过使用带有 Restriction 和 QueryString 的 FindItem,但似乎都没有给出任何结果。

有没有办法这样做?我熟悉“FindConversations”操作,但它似乎返回文件夹中所有对话的所有消息。我想要特定对话的消息。

这是我尝试过的 2 个示例 XML 请求。

尝试使用 QueryString:

<?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_SP1" />
  </soap:Header>
  <soap:Body>
    <m:FindItem Traversal="Shallow">
      <m:ItemShape>
        <t:BaseShape>AllProperties</t:BaseShape>
        <t:AdditionalProperties>
          <t:FieldURI FieldURI="item:Subject" />
          <t:FieldURI FieldURI="item:DateTimeReceived" />
          <t:FieldURI FieldURI="message:From" />
        </t:AdditionalProperties>
      </m:ItemShape>
      <m:IndexedPageItemView MaxEntriesReturned="10" Offset="0" BasePoint="Beginning" />
      <m:ParentFolderIds>
          <t:DistinguishedFolderId Id="inbox"/>
      </m:ParentFolderIds>
      <m:QueryString>item:ConversationId:AAQkADg5MmFjNTViLTYwODUtNGNmYi04MzhjLTczZTdkOTZmYjllNwAQAA/J3OiwUmlBntyd9PhAWBM=</m:QueryString>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>

尝试使用限制:

<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_SP1" />
  </soap:Header>
  <soap:Body>
    <m:FindItem Traversal="Shallow">
      <m:ItemShape>
        <t:BaseShape>IdOnly</t:BaseShape>
      </m:ItemShape>
      <m:IndexedPageItemView MaxEntriesReturned="50" Offset="0" BasePoint="Beginning" />
      <m:Restriction>
          <t:IsEqualTo>
            <t:FieldURI FieldURI="item:ConversationId" />
            <t:FieldURIOrConstant>
              <t:Constant Value="AAQkADg5MmFjNTViLTYwODUtNGNmYi04MzhjLTczZTdkOTZmYjllNwAQAA/J3OiwUmlBntyd9PhAWBM="/>
            </t:FieldURIOrConstant>
          </t:IsEqualTo>
      </m:Restriction>
      <m:SortOrder>
        <t:FieldOrder Order="Descending">
          <t:FieldURI FieldURI="item:DateTimeReceived" />
        </t:FieldOrder>
      </m:SortOrder>
      <m:ParentFolderIds>
        <t:DistinguishedFolderId Id="inbox" />
      </m:ParentFolderIds>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>
4

2 回答 2

4

我能够根据 ConversationIndex 搜索消息。我在 Java/Android 上使用“JWebServices for Exchange”API。您必须使用有限制的 findItem 方法并使用 PR_CONVERSATION_INDEX 字段(标准 MAPI 属性)。代码就像:

        IsEqualTo restriction = new IsEqualTo(MapiPropertyTag.PR_CONVERSATION_INDEX, "AA3OiwUmlB...");

        FindItemResponse response = service.findItem(StandardFolder.INBOX, restriction);
于 2013-09-29T05:39:21.603 回答
2

这似乎几乎可以工作,但它只返回一个文件夹中的项目......不是所有文件夹;-(

请注意 PR_CONVERSATION_INDEX = 0x0071

<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="5" Offset="0" BasePoint="Beginning"/>
      <m:Restriction>
        <t:Or>
          <t:IsEqualTo>
            <t:ExtendedFieldURI PropertyTag="0x0071" PropertyType="Binary"/>
            <t:FieldURIOrConstant>
              <t:Constant Value="Ac7BH8JjB509L0wAfEakbAl7ATtZhA=="/>
            </t:FieldURIOrConstant>
          </t:IsEqualTo>
          <t:IsEqualTo>
            <t:ExtendedFieldURI PropertyTag="0x0071" PropertyType="Binary"/>
            <t:FieldURIOrConstant>
              <t:Constant Value="AQHOgWGUK7JmFnIm5E6tWXtmj4J2FplmRcIA"/>
            </t:FieldURIOrConstant>
          </t:IsEqualTo>
          <t:IsEqualTo>
            <t:ExtendedFieldURI PropertyTag="0x0071" PropertyType="Binary"/>
            <t:FieldURIOrConstant>
              <t:Constant Value="AQHOcazuyUKjqFgn8Eq0mqIHnczJhplGdo5DgABT/gA="/>
            </t:FieldURIOrConstant>
          </t:IsEqualTo>
        </t:Or>
      </m:Restriction>
      <m:ParentFolderIds>
        <t:DistinguishedFolderId Id="inbox"/>
      </m:ParentFolderIds>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>
于 2013-10-04T18:33:46.807 回答