Controlling Mailbox Cleanup
Controlling Mailbox Cleanup
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
You can automatically clean up deleted messages from mailboxes by setting the garbage collection properties on the mailbox. To limit how long the store keeps deleted mail, set the IMailboxStore::DaysBeforeGarbageCollection property to the number of days to keep the deleted mail. When no value is set, the global mailbox store setting is used.
To require that the store is backed up before it removes deleted mail, set the IMailboxStore::GarbageCollectionOnlyAfterBackup property to True.
Finally, to prevent the store from removing deleted mail, set the IMailboxStore::OverrideStoreGarbageCollection property to True.
For more information, see the DaysBeforeDeletedMailboxCleanup property on the IMailboxStoreDB interface.
Example
This example cleans up files seven days after a backup.
Visual Basic
Sub Set_Cleanup(recipname As String, _ DomainName As String) 'DomainName is something like "DC=MYDOMAIN3,DC=example,DC=com" 'recipname is something like "jamessmith" Dim objUser As IADsUser Dim objMailbox As CDOEXM.IMailboxStore Set objUser = GetObject("LDAP://CN=" + recipname + _ ",CN=users," + DomainName) Set objMailbox = objUser If objMailbox.HomeMDB = "" Then MsgBox "No mailbox found." Else objMailbox.OverrideStoreGarbageCollection = True objMailbox.GarbageCollectOnlyAfterBackup = True objMailbox.DaysBeforeGarbageCollection = 7 'commit the changes objUser.SetInfo End If End Sub
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.