Platform SDK: Active Directory, ADSI, and Directory Services

Retrieving Email Addresses

Exchange directory objects can have multiple email addresses of different types.

Address Type Exchange Name LDAP Name
Primary SMTP E-Mail Addresses for a Mailbox.

E-Mail Address for an SMTP Custom recipient (which is also stored in "Target-Address")

mail and rfc822Mailbox
Secondary SMTP E-Mail Addresses (smtp:) otherMailbox
X.400 Address E-Mail Addresses (X400:) textEncodedORAddress
Other Proxy Addresses E-Mail Addresses (MS: or CCMAIL:) otherMailbox

The otherMailbox attribute may have multiple values and contains the address type prefixed to the address.

Note  Email address types and addresses in the otherMailbox attribute are separated by a "$". For example: "CCMAIL$User at Post office".

An uppercase address type indicates the Reply To address.

Dim objMailbox As IADs
Dim varAddrs As Variant
 
Set objMailbox = _
        GetObject("LDAP://Server/cn=Mailbox,cn=Recipients,ou=Site,o=Org")
 
' Retrieve and print the smtp address
Debug.Print objMailbox.Get("mail")
Debug.Print objMailbox.Get("rfc822Mailbox")
 
'Retrieve and print the X.400 address
Debug.Print objMailbox.Get("textencodedORaddress")
 
'Load the other proxy addresses into the property cache
objMailbox.GetInfoEx Array("otherMailbox"), 0
varAddrs = objMailbox.GetEx("otherMailbox")
 
'Now varAddrs is an array of strings
For i = LBound(varAddrs) To UBound(varAddrs)
    Debug.Print varAddrs(i)
Next I
 
Set objMailbox = Nothing

Note: This example is specific to Exchange Server version 5.5 and below, and is not upwardly compatible with Exchange 6.0. Management and access of Exchange 6.0 Servers should be made through the CDO Exchange Management interfaces instead.