Platform SDK: CDO 1.2.1

Add Method (AddressEntries Collection)

The Add method creates and returns a new AddressEntry object in the AddressEntries collection.

Syntax

Set objAddressEntry = objAddrEntriesColl.Add(emailtype [, name] [, address ] )

objAddressEntry
On successful return, contains the new AddressEntry object.
objAddrEntriesColl
Required. The AddressEntries collection object.
emailtype
Required. String. The address type of the address entry.
name
Optional. String. The display name or alias of the address entry.
address
Optional. String. The full messaging address of the address entry.

Remarks

The emailtype parameter corresponds to the PR_ADDRTYPE property and qualifies the address parameter by specifying which messaging system the address is valid in. Typical values are SMTP, FAX, and X400.

The emailtype, name, and address parameters correspond to the Type, Name, and Address properties of the AddressEntry object.

You can set the emailtype parameter to any string recognized and supported by the address book providers invoked by the current profile, such as SMTP or X400. In particular, if you are using the Microsoft® Exchange private address book (PAB) provider, you can set emailtype to MAPIPDL to indicate a private distribution list (PDL).

The DisplayType property of the new AddressEntry object is set by the address book provider to either CdoUser or CdoDistList, depending on which kind of address entry is being added. The DisplayType property is read-only and cannot subsequently be changed.

The user must have the appropriate permission to Add, Delete, or Update an AddressEntry object. Most users have this permission only for their personal address book (PAB).

The CDO Library does not support addition, deletion, or modification of members of a distribution list (DL) on the global address list (GAL).

The new AddressEntry object is saved in the MAPI system when you call its Update method.

Example

This code fragment adds a new entry to a user's personal address book (PAB). Note the use of the Item property as the default property of the AddressLists collection.

' get PAB AddressList from AddressLists collection of Session 
Dim myList As AddressList ' used to obtain PAB 
Dim newEntry As AddressEntry ' new user in PAB 
Dim newField As Field ' fax number of new user 
' assume objSession created and logged on to without problem 
Set myList = objSession.AddressLists("Personal Address Book") 
' add new AddressEntry to AddressEntries collection of AddressList 
Set newEntry = myList.AddressEntries.Add("FAX", "John Doe") 
' add FaxNumber field to new AddressEntry and give it a value 
Set newField = newEntry.Fields.Add("FaxNumber", vbString) 
newField.Value = "+1-206-555-7069" ' could have supplied this in Add 
' commit new entry, field, and value to PAB AddressList 
newEntry.Update