Platform SDK: Exchange 2000 Server

Building a Restricted Address List

[This is preliminary documentation and subject to change.]

Example

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

[Visual Basic]
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