Platform SDK: Exchange 2000 Server

Enumerating Recipients

[This is preliminary documentation and subject to change.]

Example

This example lists the recipients in an Exchange 2000 information store. This example opens the user information in the Active Directory using ADSI. It then uses the IMailboxStore interface aggregated onto the ADSI.user object to access information in the Web Store.

[Visual Basic]
Sub List_Users(ServerName As String, DomainName As String)

'ServerName is something like "MyServer6"
'DomainName is something like "DC=MYDOMAIN3,DC=microsoft,DC=com"

Dim objUser As IADsUser
Dim objContainer As IADsContainer
Dim objMailbox As CDOEXM.IMailboxStore
Dim i As Long
Dim name As String

On Error GoTo Error
' get the container
Set objContainer = GetObject("LDAP://" + ServerName + "/" + _
                            "CN=users," + DomainName)
                            
objContainer.Filter = Array("User")
i = 0

Debug.Print

For Each objUser In objContainer
   name = objUser.name
   name = Right(name, Len(name) - 3)
   Set objMailbox = objUser
   If objMailbox.HomeMDB = "" Then
      Debug.Print name + "   (no mailbox)"
   Else
      Debug.Print name + "   (has mailbox)"
      Debug.Print objMailbox.HomeMDB
   End If
   i = i + 1
Next
Debug.Print "Number of users found in the DS (in the default container): " + Str(i)
GoTo Ending

Error:
   Debug.Print "Failed while displaying the users in the default container."
   MsgBox "Run time error: " + Str(Err.number) + " " + Err.Description
   Err.Clear
Ending:

End Sub