Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

How to: Delete 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

    -or-

    Visual Studio Team System

  • Microsoft Office Outlook 2003

NoteNote

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 deletes a contact. The example assumes that a contact named "Armando Pinto" exists in the Contacts folder.

Example

    private void ThisApplication_Startup(object sender, System.EventArgs e)
    {
        DeleteContact("Pinto", "Armando");
    }

private void DeleteContact(string lastName, string firstName)
{
    Outlook.ContactItem contact =
        this.GetNamespace("MAPI").
    GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).
    Items.
    Find(
    string.Format("[LastName]='{0}' AND [FirstName]='{1}'",
    lastName, firstName))
    as Outlook.ContactItem;

    if (contact != null)
    {
        contact.Delete();
    }
}

See Also

Community Additions

ADD
Show:
© 2015 Microsoft