Platform SDK: Exchange 2000 Server

Creating a Mail-Enabled Recipient

[This is preliminary documentation and subject to change.]

To create a mail-enabled recipient you must first create an object that supports the IMailRecipient interface:

In most cases you create an instance of a Person object. Note that if the user does not have an Exchange mailbox, you must set their address using the IMailRecipient.MailEnable method.

Example (CDOEXM)

This example creates a mail recipient who can access mail through HTTP. The recipient is limited to sending and receiving messages no larger than 50KB.

[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