vbaoutlookretention

How to assign a retention tag to a mail item in Outlook VBA?


I'm trying to write a macro which will be going through a folder in Outlook assigning a retention tag (docs) to some items based on some complicated criteria.

I don't know how to do this in VBA. So far I've learned that mail items have some retention related properties (PidTagPolicyTag (docs), etc.), but I still don't know how to deal with them properly.

What would be some examples of using with these?


Solution

  • Take a look at an existing message with these properties set using OutlookSpy (I am its author - click IMessage) or MFCMAPI. PR_POLICY_TAG / PR_RETENTION_PERIOD / PR_RETENTION_DATE properties can be set using MailItem.PropertyAccessor.SetProperty.