Export (0) Print
Expand All

How to: Access Outlook Contacts

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Application-level projects

Microsoft Office version

  • Outlook 2003

  • Outlook 2007

For more information, see Features Available by Application and Project Type.

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

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

private void AccessContacts(string findLastName)
    Outlook.MAPIFolder folderContacts = this.Application.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 + ".");

This example requires:

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

Community Additions

© 2014 Microsoft