Share via


Building a Restricted Address List

Building a Restricted Address List

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.

Example

This example adds to the restricted address list for a recipient. This involves setting the IMailRecipient.RestrictedAddresses property to either cdoReject or cdoAccept and adding to the IMailRecipient.RestrictedAddressList.

Visual Basic

Note  The following example uses a file URL with the Exchange OLE DB (ExOLEDB) provider. The ExOLEDB provider also supports The HTTP: URL Scheme. Using The HTTP: URL Scheme allows both client and server applications to use a single URL scheme.

Sub RestrictAddresses(DomainName As String, _
                      FolderName As String)

    'DomainName is something like "MyDomain.wherever.com"
    'FolderName is something like "Public Folders/Folder3"

    Dim objFolder As New CDO.Folder
    Dim objMailRecip As CDOEXM.IMailRecipient
    Dim fullurl As String
    Dim i

    'fullurl might look like:
    ' "file://./backofficestorage/MyDomain.wherever.com/Public Folders/Folder3"
    fullurl = "file://./backofficestorage/" + _
              DomainName + "/" + FolderName

    objFolder.DataSource.Open fullurl, , adModeReadWrite, adFailIfNotExists

    Set objMailRecip = objFolder

    ' can build an accept or reject list
    objMailRecip.restrictedAddresses = cdoReject 'reject these emails

    Dim list(3) As Variant

    list(0) = "user@" + DomainName
    list(1) = "user1@" + DomainName
    list(2) = "user2@" + DomainName

    objMailRecip.RestrictedAddressList = list
    objFolder.DataSource.Save

    'look at the results
    Debug.Print Chr(13) + Chr(13) + "View list"
    For i = LBound(objMailRecip.RestrictedAddressList) To UBound(objMailRecip.RestrictedAddressList)
      Debug.Print objMailRecip.RestrictedAddressList(i)
    Next

    MsgBox "Mailbox restrictions for " + FolderName + " set successfully"

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.