微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Exchange:使用XML请求在EWS对话中查找项目?

我正在尝试使用Exchange EWS 2010查找对话中的项目,无论他们在哪个文件夹中.我不想在单个文件夹中获取所有conversationId的列表.我想逐个查询对话.

我在Android上这样做,并且已经为其他EWS请求发送XML soap请求.

我的问题是:

如果是ConversationId,XML应如何格式化以在单个对话中检索项目?

我已经尝试使用FindItem with Restriction和QueryString,但似乎都没有给出任何结果.

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

以下是我尝试过的两个示例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>

解决方法

我能够根据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);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。