使用 EWS 创建 Exchange 消息项目并将其标记为删除

Create Exchange Message Items with EWS and mark them for deletion

我正在使用 EWS 在 Exchange 邮箱中创建项目。我正在使用 CreateItems 方法。我还在我创建的项目上设置了扩展 属性,以便在到达该日期时将其删除。项目已正确创建,但未在指定日期删除。

我了解到 Exchange 中有一个计时器作业,它根据项目上的扩展 属性 设置进行实际处理,我可以在 Powershell 中使用 "Start-ManagedFolderAssistant -Identity user@example.com" 来强制执行该作业,但这也不起作用。

这是我要发送的消息:

<?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="Exchange2013" />
  </soap:Header>
  <soap:Body>
    <m:CreateItem MessageDisposition="SaveOnly">
      <m:SavedItemFolderId>
        <t:DistinguishedFolderId Id="root" />
      </m:SavedItemFolderId>
      <m:Items>
        <t:Message>
          <t:ItemClass>IPM.Blabla</t:ItemClass>
          <t:Subject>ToDelete</t:Subject>
          <t:Body BodyType="Text">Todelete</t:Body>
           <t:ExtendedProperty>
              <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c3e" 
                 PropertyName="Expiration Date" PropertyType="String" />
              <t:Value>6/4/2015 2:39:04 PM</t:Value>
            </t:ExtendedProperty>
        </t:Message>       
      </m:Items>
    </m:CreateItem>
  </soap:Body>
</soap:Envelope>

消息中是否缺少某些内容以致作业将其删除?我对系统的工作方式有什么误解吗?

属性 您的设置不会执行任何操作,看起来您从 https://msdn.microsoft.com/en-us/library/office/dd633654%28v=exchg.80%29.aspx 中提取了示例,这只是创建自定义 属性 供您自己使用的示例.没有后端进程会使用您刚创建的 属性。

在 Outlook/Exchange 中有两种过期方法,第一种是使用 PidtagExpirytime https://msdn.microsoft.com/en-us/library/ee237103%28v=exchg.80%29.aspx . This is a client mechanism and there is still no server process to delete the expired messages see http://www.msoutlook.info/question/automatically-delete-message-at-set-date . The Server side method is to stamp the messages with a Retention tag that will specify when the message will be deleted eg http://blogs.msdn.com/b/akashb/archive/2011/08/11/stamping-retention-policy-tag-using-ews-managed-api-1-1-from-powershell-exchange-2010.aspx and in 2013 you can do this via https://msdn.microsoft.com/en-us/library/office/jj220500%28v=exchg.80%29.aspx#ret

干杯 格伦