You are currently offline, waiting for your internet to reconnect

How to use address books in an Outlook solution

This article was previously published under Q291147
For a Microsoft Outlook 98 version of this article, see 193457.

For a Microsoft Outlook 2000 version of this article, see 231290.
This article provides an overview of data that you have access to in address books. It also discusses how you can programmatically display an address book dialog box.

To Access Address Book Data

Using the Microsoft Outlook object model, you can access information that is stored in various address books. For example, you can retrieve information about entries in the Global Address Book, or an Outlook Address Book. To see the type of information you have access to, consult the AddressEntry object topic in the Microsoft Outlook Visual Basic Reference (Vbaol10.chm). Click the Properties link on that page to see the list of properties available for an entry in an address book.

If you want to access additional entries that are typically available for a recipient (such as Office, Title or Phone) you can use the Collaboration Data Objects (CDO) object model. For additional information about accessing these properties using CDO, click the following article numbers to view the articles in the Microsoft Knowledge Base:
179083 How To Use CDO (1.x) To Read MAPI Address Book Properties
178787 How To Work with Distribution Lists Using CDO (1.x) from Visual Basic

To Display an Address Book Dialog Box

The Outlook object model does not support displaying a dialog box for a user to select recipients from an address book. To implement an address book dialog box in your solution, use the appropriate method.

Method 1

The preferred method of displaying an address book dialog box is to use the AddressBook method in the CDO object model. Typically, you would add a Command Button control to the Outlook form and in the Click event for the button you would automate the CDO object model from Visual Basic Scripting Edition (VBScript).

An advantage of using CDO to display the Address Book is that you can customize the appearance of the dialog box to suit your needs. For more information about using CDO to display the Address Book dialog box, consult the CDO documentation at the following Microsoft Web site:
The AddressBook method documentation is located at the following Microsoft Web site:

Method 2

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners -

Microsoft Advisory Services -

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:;EN-US;CNTACTMS Use a command button control on an Outlook form that is bound to a recipient field (such as the To field). If a command button is bound to a recipient field, when the user clicks the button, Outlook displays the address book dialog box and the recipient that the user selects will be added to the field.

NOTE: Although Outlook items other than a mail message do not have recipients fields, these fields are functional on non-mail forms even though they are not listed in the set of fields available for that particular item. You cannot directly access these fields from VBScript, because the Outlook object model does not consider these to be valid properties of items that are not MailItems. However, as the steps that follow illustrate, you can "filter" the data through another valid field to access the user's selection from VBScript.

The following steps illustrate how to set up a command button on an Outlook Contact form that will display the address book dialog box. This approach will work on form types other than a contact form.

  1. Open a new Contact form.
  2. On the Tools menu, click Forms, and then click Design This Form.
  3. Click the (P.2) page of the form.
  4. Set the Field Chooser to display All Mail Fields, and then drag the To field onto the (P.2) page of the form.
  5. Right-click To..., and click Properties. Change the name to cmdSelectManager, change the caption to Select Manager..., and click OK. Resize the controls on the P.2 page as needed.
  6. On the Field Chooser, click New... and create a user-defined text field called MyTo.
  7. Drag the MyTo field onto the P.2 page of the form. Right-click the text box for the MyTo field and then click Properties. On the Value page of the Properties dialog box, click to select the Set the initial value of this field to: check box, and type [To] in the text box. Click to select Calculate this formula automatically, and then click OK.
  8. Using the Control Toolbox, drag a command button onto the form. This is typically named CommandButton1.
  9. On the Form menu, click View Code. Type the following VBScript code and then close the Script Editor. Make sure the name of the command button in code matches the name of the command button added in Step 8.
    Sub CommandButton1_Click()   MsgBox Item.UserProperties.Find("MyTo")End Sub					
To test the form, follow these steps:
  1. On the Form menu, click Run This Form.
  2. Click the P.2 page of the form, and click Select Manager.
  3. When the dialog box appears, click to select a name, and click To-> to add the name to the list of recipients. Click OK.
The selected name will appear in the text box on the form, which is also bound to the To field. The selected name will now appear in the MyTo field, because that field is set to be based automatically on the To field. Click the CommandButton1 control to see the selected manager displayed in VBScript.

NOTE: It is not possible to change any of the labels or strings in this Address Book dialog box, as you can with the dialog box created using CDO.
For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:
287530 OL2002: Questions About Custom Forms and Outlook Solutions
OutSol OutSol2002

Article ID: 291147 - Last Review: 03/29/2007 06:48:47 - Revision: 4.5

  • Microsoft Outlook 2002 Standard Edition
  • kbprogramming kbaddressbook kbhowto KB291147