Platform SDK: Exchange 2000 Server

MailEnable Method

[This is preliminary documentation and subject to change.]

This method enables mail to a recipient. The recipient can be a user, folder, contact or group.

[Visual Basic,VBScript]
Subroutine MailEnable(ByVal TargetMailAddress as String)
[C++]
HRESULT MailEnable(BSTR TargetMailAddress );
[IDL]
HRESULT MailEnable([in,optional] BSTR TargetMailAddress);
TargetMailAddress
The TargetMailAddress sets the IMailRecipient.TargetAddress property.

Remarks

MailEnable method creates the proxy addresses (sets the ProxyAddresses property, and the SMTPEMail and X400Email properties).

MailEnable also sets the TargetAddress property if the object type is not a group. When MailEnable method is called with a TargetMailAddress parameter (for a recipeint or a contact) it sets the TargetAddress property.

Example (CDO)

[Visual Basic]
Sub CDOCreate_MailEnabled_Recipient(ServerName As String, _
                                    DomainName As String, _
                                    recipname As String, _
                                    forward_domain As String)
                                         
'ServerName is something like "MyServer6"
'DomainName is something like "DC=MYDOMAIN3,DC=microsoft,DC=com"
'recipname is is the email alias eg. "jamessmith"
'forward_domain is a domain like "somewhere.microsoft.com"
                                         

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 = "" And objRecip.X400Email = "" Then
   forward_email = "smtp:" + recipname + "@" + forward_domain
   objRecip.MailEnable forward_email  'where to forward the mail to
   objPerson.DataSource.Save
   objRecip.IncomingLimit = 50
   objRecip.OutgoingLimit = 50
   MsgBox recipname + " mail enabled successfully"
Else
   MsgBox recipname + " is already mail enabled"
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 Sub