Article ID: 196507
Article Last Modified on 9/12/2005
' 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 SubKeywords: kbhowto kbmsg kbfaq KB196507