Platform SDK: Exchange 2000 Server

Disabling a Mail Recipient

[This is preliminary documentation and subject to change.]

Call the IMailRecipient.MailDisable method to disable a mail recipient. The IMailRecipient interface is aggregated onto the Person object.

Example

[Visual Basic]
Function CDODisable_Recipient(ServerName As String, _
                              DomainName As String, _
                              recipname As String) As Integer

'ServerName is something like "MyServer6"
'DomainName is something like "DC=MYDOMAIN3,DC=microsoft,DC=com"
'recipname is is the email alias eg. "jamessmith"

    Dim objPerson As New CDO.Person
    Dim objRecip As CDOEXM.IMailRecipient
    Dim forward_email As String
    
    On Error GoTo Error
    
    objPerson.DataSource.Open "LDAP://" + ServerName + _
                                "/CN=" + recipname + _
                                ",CN=users," + DomainName
    
    Set objRecip = objPerson
    
    If (objRecip.TargetAddress <> "") Or (objRecip.X400Email <> "") Then
       objRecip.MailDisable
       objPerson.DataSource.Save
       MsgBox recipname + " mail disabled"
    End If
       
    
    GoTo Ending
    
Error:
    If Err.number = -2147016656 Then
       MsgBox recipname + " not found."
       Err.Clear
    Else
       MsgBox "Run time error: " + Str(Err.number) + " " + Err.Description
       Err.Clear
    End If
       
Ending:
End Function