How to retrieve alternate e-mail addresses by using CDO (196507)



The information in this article applies to:

  • Collaboration Data Objects (CDO) 1.0a
  • Collaboration Data Objects (CDO) 1.1
  • Collaboration Data Objects (CDO) 1.2
  • Collaboration Data Objects (CDO) 1.21

This article was previously published under Q196507

SUMMARY

This article contains a Collaboration Data Objects (1.x) code sample that demonstrates how to access the PR_EMS_AB_PROXY_ADDRESSES field of the AddressEntry object. This property contains the foreign system e-mail addresses (alternate e-mail addresses).

MORE INFORMATION

You can see the list of foreign system e-mail addresses (alternate e-mail addresses) through Microsoft Outlook as follows:
  1. From the Outlook standard toolbar, click Address Book.
  2. Right-click a name from the Exchange Global Address List and click Properties.
  3. Click the E-mail Addresses tab.
Microsoft Exchange Server supports the following types of addresses:
  • Exchange
  • Microsoft Mail
  • MacMail
  • X.400
  • Internet
  • Lotus cc:Mail
  • Custom
Each recipient on a Microsoft Exchange Server can have one or more of these types of addresses. The Address property of the AddressEntry object returns the Exchange (EX) type e-mail address by default. To retrieve the other addresses, you can use the PR_EMS_AB_PROXY_ADDRESSES property.

Not all address book providers support the PR_EMS_AB_PROXY_ADDRESSES property. The Exchange Global Address List (GAL) does, and it is also present in Personal Address Book (PAB) entries that were copied from the Exchange GAL. Outlook Contact folders do not support this property.

The following Visual Basic code uses CDO (1.x) to access the PR_EMS_AB_PROXY_ADDRESSES property:

Sample code

   ' This code sample assumes a valid reference to CDO (1.x) library.
   ' To use CDO (1.0) library, however, you must declare all CDO objects
   ' variables as Object. For example, "Dim objSession As Object."

   Option Explicit

   ' This constant is not included in the CDO (1.x) type library,
   ' so you must declare it explicitly or use the provided
   ' value directly.
   Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E

   Private Sub Command1_Click()
     Dim objSession As MAPI.Session
     Dim objMessage As MAPI.Message
     Dim objRecip As MAPI.Recipient
     Dim objField As MAPI.Field
     Dim v

     ' Create Session object and Logon.
     Set objSession = CreateObject("MAPI.Session")
     objSession.Logon

     ' Show AddressBook and choose a recipient.
     Set objMessage = objSession.Outbox.Messages.Add
     Set objMessage.Recipients = objSession.AddressBook(OneAddress:=True)
     Set objRecip = objMessage.Recipients(1)

     ' Show the display name and EX type address.
     MsgBox "Display Name: " & objRecip.Name
     MsgBox "Default Address: " & objRecip.Address

     ' Get the PR_EMS_AB_PROXY_ADDRESSES property.
     Set objField = _
        objRecip.AddressEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)

     ' PR_EMS_AB_PROXY_ADDRESSES is a multivalued property (PT_MV_TSTRING).
     ' Therefore, you need to extract the individual members.
     For Each v In objField.Value
         MsgBox "Foreign System Address: " & v
     Next

     ' Clean up and exit.
     Set objMessage = Nothing
     Set objRecip = Nothing
     Set objField = Nothing
     objSession.Logoff
     Set objSession = Nothing
     Unload Me
   End Sub

Modification Type:MajorLast Reviewed:9/12/2005
Keywords:kbFAQ kbhowto kbMsg KB196507