首页 > 解决方案 > 如何在 EWS 的最后一天收到消息?

问题描述

我正在 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>"@

标签: powershellexchangewebservices

解决方案


您应该能够将收到的:昨天添加到您的查询字符串中,例如

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


推荐阅读