Freigeben über


Want to set Retention tags with EWS?

I put together some information to help with writing code to set retention tags on a folder.  The articles at the end will go over how the retention properties are used in code, one has a sample which shows setting the retention tags on a folder using PowerShell and the EWS Managed API and the last is to a Microsoft MVP blog where there is a large quantity of samples which you might be able to leverage.

About: Exchange Web Services (EWS) – Getting started with EWS
https://blogs.msdn.microsoft.com/webdav_101/2015/05/03/getting-started-with-ews/

EWSEditor has code in it which can set tags on a folder – you can access that functionality by right clicking on a folder (FolderRetentionSettings.cs).  You will need the policy GUID from ECP in order to add a tag. Under the Tools menu is a window which will show the policies for a mailbox (UserRetentionTagPolicyTagsForm.cs) and also let you search mailbox to see where a tag is applied.  The full source is downloadable.

https://ewseditor.codeplex.com/

Here are the related properties:

        private
static
ExtendedPropertyDefinition Prop_PR_START_DATE_ETC = new
ExtendedPropertyDefinition(0x3019, MapiPropertyType.SystemTime);

        private
static
ExtendedPropertyDefinition Prop_PR_POLICY_TAG = new
ExtendedPropertyDefinition(0x301B, MapiPropertyType.Binary);     

        private
static
ExtendedPropertyDefinition Prop_PR_RETENTION_FLAGS = new
ExtendedPropertyDefinition(0x301D, MapiPropertyType.Integer);    

        private
static
ExtendedPropertyDefinition Prop_PR_RETENTION_PERIOD = new
ExtendedPropertyDefinition(0x301A, MapiPropertyType.Integer);    

        private
static
ExtendedPropertyDefinition Prop_PR_RETENTION_DATE = new
ExtendedPropertyDefinition(0x301C, MapiPropertyType.SystemTime);  

Articles:

Search and Replace Retention tag on Microsoft Exchange 2010 (MRM) https://blogs.technet.microsoft.com/surama/2011/10/19/search-and-replace-retention-tag-on-microsoft-exchange-2010-mrm/

Stamping Retention Policy Tag using EWS Managed API 1.1 from PowerShell(Exchange 2010) https://blogs.msdn.microsoft.com/akashb/2011/08/10/stamping-retention-policy-tag-using-ews-managed-api-1-1-from-powershellexchange-2010/

Note: You will need to alter this sample per your needs. Be sure to change out the GUID used with the one for the policy from ECP.

Glean Scales blog – It has a lot of Exchange PowerShell script samples which use the EWS Managed API.
https://gsexdev.blogspot.com