This documentation is archived and is not being maintained.

How to: Access Outlook Contacts

Note Required applications

The code example in this topic can be compiled only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005


    Visual Studio Team System

  • Microsoft Office Outlook 2003


This code does not compile if you use the VSTO 2005 SE version of the Outlook 2003 add-in project template. For more information, see Getting Started Programming Application-Level Add-ins.

This example finds all contacts whose last names contain a specified search string.


private void ThisApplication_Startup(object sender, System.EventArgs e)

private void AccessContacts(string findLastName)
    Outlook.MAPIFolder folderContacts = this.ActiveExplorer().Session.
    Outlook.Items searchFolder = folderContacts.Items;
    int counter = 0;
    foreach (Outlook.ContactItem foundContact in searchFolder)
        if (foundContact.LastName.Contains(findLastName))
            counter = counter + 1;
    MessageBox.Show("You have " + counter +
        " contacts with last names that contain "
        + findLastName + ".");

Compiling the Code

This example requires:

  • Contacts whose last names contain the string "Na" (for example, Tzipi Butnaru) in the Contacts folder.

See Also