Platform SDK: Exchange 2000 Server

DeleteMailBox Method

[This is preliminary documentation and subject to change.]

This method deletes a mailbox at a specified URL.

[Visual Basic,VBScript]
Sub DeleteMailBox As Boolean
[C++]
HRESULT DeleteMailBox();
[IDL]
HRESULT DeleteMailBox();

Remarks

Example (CDO)

[Visual Basic]
Sub Delete_MailBoxCDO(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 objPerson As New CDO.Person
Dim objMailbox As CDOEXM.IMailboxStore

objPerson.DataSource.Open "LDAP://" + ServerName + _
                            "/CN=" + recipname + _
                            ",CN=users," + DomainName

Set objMailbox = objPerson
If objMailbox.HomeMDB = "" Then
   MsgBox "No Mailbox found."
Else
   objMailbox.DeleteMailbox
   objPerson.DataSource.Save
   MsgBox "Mailbox for " + recipname + " deleted successfully"
End If

End Sub

Example (ADSI)

[Visual Basic]
Sub Delete_MailBoxADSI(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.DeleteMailbox
   objUser.SetInfo
   MsgBox "Mailbox for " + recipname + " deleted successfully"
End If

End Sub