HOWTO: Retrieve Alternate E-mail Addresses Using CDO
ID: Q196507
|
The information in this article applies to:
-
Collaboration Data Objects (CDO), versions 1.0a, 1.1, 1.2, 1.21
SUMMARY
This article contains a CDO 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:
- From the Outlook standard toolbar, click Address Book.
- Right-click on a name from the Exchange Global Address List and click
Properties.
- 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 to access the
PR_EMS_AB_PROXY_ADDRESSES property:
Sample Code
' This code sample assumes a valid reference to CDO version 1.1 (or
' later) library. To use CDO version 1.0 (Ole Messaging) library, 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 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
Additional query words:
Keywords : kbActMsg kbCDO100a kbCDO110 kbCDO120 kbCDO121 kbMsg kbOLEMsg kbVBp kbfaq kbGrpMsg
Version : WINDOWS:1.0a,1.1,1.2,1.21
Platform : WINDOWS
Issue type : kbhowto