Export (0) Print
Expand All

How to: Programmatically Delete Outlook Contacts

This example deletes a contact. The example assumes that a contact named "Armando Pinto" exists in the Contacts folder.

Applies to: The information in this topic applies to application-level projects for Outlook 2013 and Outlook 2010. For more information, see Features Available by Office Application and Project Type.

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

private void DeleteContact(string lastName, string firstName)
{
    Outlook.ContactItem contact =
        this.Application.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();
    }
}
Show:
© 2015 Microsoft