Creating a Mail-Enabled Recipient
Creating a Mail-Enabled Recipient

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
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View