如何在EWS的最后一天获取消息?

时间:2018-10-15 13:11:09

标签: powershell exchangewebservices

我正在PowerShell中编写一些脚本,我想从电子邮件中获取消息。 我有一个xml从EWS获取所有消息,但是我只想从昨天获取消息。 谁能帮助我做到这一点?

$getInbox= @"
  <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2013_SP1"/>
  </soap:Header>
  <soap:Body>
    <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
              xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
              Traversal="Shallow">
      <ItemShape>
        <t:BaseShape>IdOnly</t:BaseShape>
      </ItemShape>
      <ParentFolderIds>
        <t:DistinguishedFolderId Id="inbox"/>
     </ParentFolderIds>
     <QueryString>HasAttachments:true From:myEmail Kind:email</QueryString>
    </FindItem>
  </soap:Body>
</soap:Envelope>"@

1 个答案:

答案 0 :(得分:0)

您应该只可以在昨天的查询字符串中添加receive ::昨天

<QueryString>HasAttachments:true From:myEmail Kind:email received:yesterday</QueryString>