Changing an Existing Address Entry

Changing an Existing Address Entry

The CDO Library lets you change existing address entries in any address book container for which you have modification permission. Typically you have such permission only for your personal address book (PAB).

ms526180.787845a5-a0eb-4ef0-a02b-af44a9f76e33(en-us,EXCHG.10).gif

To change an existing address entry

  1. Select the AddressEntry object to modify. You can obtain the AddressEntry object in several ways, including the following:
    • Call the Session object’s AddressBook method to let the user select recipients. The method returns a Recipients collection. Examine each Recipient object’s AddressEntry property to obtain its child AddressEntry object.
    • Use the Message object’s Sender property to obtain an AddressEntry object.
    • Use the Message object’s Recipients property to obtain a Recipients collection. Then obtain an individual Recipient object and use its AddressEntry property to obtain its child AddressEntry object.
  2. Change individual properties of the AddressEntry object, such as the Address, Name, or Type property.
  3. Call the AddressEntry object’s Update method.

The following sample code demonstrates this procedure:

' Function: AddressEntry_Update
' Purpose: Demonstrate the Update method
' See documentation topic: Update method AddressEntry object
Function AddressEntry_Update()
Dim objRecipColl As Recipients  ' Recipients collection
Dim objNewRecip As Recipient    ' New recipient object

On Error GoTo error_olemsg
If objSession Is Nothing Then
    MsgBox "must log on first"
    Exit Function
End If
Set objRecipColl = objSession.AddressBook ' let user select
If objRecipColl Is Nothing Then
    MsgBox "must select someone from the address book"
    Exit Function
End If
Set objNewRecip = objRecipColl.Item(1)
With objNewRecip.AddressEntry
    .Name = .Name & " MD, PhD"
    .Type = "X.500" ' you can update the type, too ...
    .Update
End With
MsgBox "Updated address entry name: " & objNewRecip.AddressEntry.Name
Exit Function

error_olemsg:
MsgBox "Error " & Str(Err) & ": " & Error$(Err)
Resume Next

End Function
 

See Also

Using Addresses, Creating a New Address Book Entry, Selecting Recipients from the Address Book

See Also

Concepts

Programming Tasks