如何查询EWS以查找日历消息正文

时间:2016-07-07 20:17:15

标签: outlook exchange-server exchangewebservices

我正在寻找比这个答案中给出的更多细节:Exchange EWS not returning message body for calendar

具体来说,我不确定如何在查询中获取日历消息的正文。

我的XML查询是:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <m:FindItem Traversal="Shallow" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ItemShape>
                <t:BaseShape>IdOnly</t:BaseShape>
                <t:AdditionalProperties>
                    <t:FieldURI FieldURI="item:Body"/>
                    <t:FieldURI FieldURI="calendar:Start"/>
                    <t:FieldURI FieldURI="calendar:End"/>
                    <t:FieldURI FieldURI="calendar:Location"/>
                    <t:FieldURI FieldURI="item:Attachments"/>
                </t:AdditionalProperties>
            </m:ItemShape>
            <m:CalendarView EndDate="2016-07-08T00:00:00Z" MaxEntriesReturned="999999" StartDate="2016-07-07T00:00:00Z"/>
            <m:ParentFolderIds>
                <t:DistinguishedFolderId Id="calendar"/>
            </m:ParentFolderIds>
        </m:FindItem>
    </s:Body>
</s:Envelope>

但我似乎收到了错误:

<t:FieldURI FieldURI="item:Body"/>

错误消息

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="534" MinorBuildNumber="21"/>
  </s:Header>
  <s:Body>
    <m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <m:ResponseMessages>
        <m:FindItemResponseMessage ResponseClass="Error">
          <m:MessageText>Property is not valid for this operation.</m:MessageText>
          <m:ResponseCode>ErrorInvalidPropertyForOperation</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
          <m:MessageXml>
            <t:FieldURI FieldURI="item:Body"/>
          </m:MessageXml>
        </m:FindItemResponseMessage>
      </m:ResponseMessages>
    </m:FindItemResponse>
  </s:Body>
</s:Envelope>

我已经查看了API:

https://msdn.microsoft.com/en-us/library/office/aa494315(v=exchg.150).aspx

而且我认为我必须遗漏一些简单的事情。有没有办法使用特定的基于字段的查询来获取日历正文?

由于

1 个答案:

答案 0 :(得分:0)

FindItem操作不会返回Body,Attendees和其他复杂/大型属性,请参阅https://blogs.msdn.microsoft.com/vikas/2007/07/26/ews-why-does-not-finditem-return-all-the-fields-you-expected/

因此,您需要从FindItem请求中获取ItemId,然后创建单个GetItem请求https://msdn.microsoft.com/en-us/library/office/aa564509(v=exchg.150).aspx,或者如果您需要多个项目,请将GetItem请求一起批处理以提高效率。