I am using EWS to create items in an Exchange mailbox. I am using the CreateItems method. I am also setting an extended property on the items I create so that it is deleted when that date is reached. The items are created correctly, but they are not deleted at the specified date.
I read that there is a timer job in Exchange that does the actual processing based on the extended property set on an item and that I could use "Start-ManagedFolderAssistant -Identity [email protected]" in Powershell to force that job, but this didn't work either.
Here is the message I am sending:
<?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>
Is there something missing with in the message so that the job deletes it? Is there something that I misunderstood in the way the system works?
That property your setting won't do anything it looks like you have pulled the sample from https://msdn.microsoft.com/en-us/library/office/dd633654%28v=exchg.80%29.aspx which is just a sample of creating a custom property for your own use. There is no back-end process that would use this property you just created.
There are two ways of doing expiry in Outlook/Exchange the first is using the 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
Cheers Glen