Share via


Creating a Mail-Enabled Recipient

Creating a Mail-Enabled Recipient

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.