To create a mail-enabled recipient, you must first create an object
that supports the
IMailRecipient interface:
- Person
- Folder
- ADSI Contact (IADS)
- ADSI Group (IADSGroup)
- ADSI User (IADSUser)
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 his or her
address by 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 50 KB.
The example uses the CreateUserURL function, which is described
in the topic Creating a User URL.
Visual Basic
Sub MailEnableCDOPerson(strUserName As String, _
strTargetMailAddress As String, _
strDomain As String)
Dim oPerson As New CDO.Person
Dim oRecipient As CDOEXM.IMailRecipient
'Target address should look like this
'strTargetMailAddress = strLastName & "@microsoft.com"
' get the user
oPerson.DataSource.Open "LDAP://CN=" + strUserName + ",CN=users," + strDomain
' MailEnable
Set oRecipient = oPerson
oRecipient.MailEnable strTargetMailAddress
oPerson.DataSource.Save
MsgBox strUserName + " mail enabled successfully"
'CleanUp
Set oPerson = Nothing
Set oRecipient = Nothing
End Sub