Platform SDK: Exchange 2000 Server

Controlling Mailbox Cleanup

[This is preliminary documentation and subject to change.]

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. The default is to keep the deleted mail indefinitely.

To require that the store is backed up before it removes deleted mail, set the IMailboxStore::GarbageCollectOnlyAfterBackup property to True.

Finally, to prevent the store from removing deleted mail, set the IMailboxStore::OverrideStoreGarbageCollection property to True.

Example

This following example cleans up files 7 days after a backup.

[Visual Basic]
Sub Set_Cleanup(ServerName As String, _
                DomainName As String, _
                recipname As String)
                                        
'ServerName is something like "MyServer6"
'DomainName is something like "DC=MYDOMAIN3,DC=microsoft,DC=com"
'recipname is something like "jamessmith"

Dim objUser As IADsUser
Dim objMailbox As CDOEXM.IMailboxStore

Set objUser = GetObject("LDAP://" + ServerName + _
                        "/CN=" + recipname + _
                        ",CN=users," + DomainName)

Set objMailbox = objUser
If objMailbox.HomeMDB = "" Then
   MsgBox "No mailbox found."
Else
   objMailbox.GarbageCollectOnlyAfterBackup = True
   objMailbox.DaysBeforeGarbageCollection = 7
   'commit the changes
   objUser.SetInfo
End If

End Sub