To remove a Business Contact object programmatically, first select the object and then call the Delete method. The following C# and Visual Basic for Applications (VBA) examples show how to select a Business Contact object.
Outlook.ContactItem contactItem = (Outlook.ContactItem)contactsFolder.Items.Find(strQuery);
if (contactItem != null)
{
contactItem.Delete();
}
else
{
Console.WriteLine("Contact not found");
}
}
Sub DeleteBusinessContact()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolders As Outlook.Folders
Dim bcmRootFolder As Outlook.Folder
Dim bcmContactsFldr As Outlook.Folder
Dim existContact As Outlook.ContactItem
Set olApp = CreateObject("Outlook.Application")
Set objNS = olApp.GetNamespace("MAPI")
Set olFolders = objNS.Session.Folders
Set bcmRootFolder = olFolders("Business Contact Manager")
Set bcmContactsFldr = bcmRootFolder.Folders("Business Contacts")
Set existContact = bcmContactsFldr.Items.Find("[FileAs] = 'John Smith'")
If Not TypeName(existContact) = "Nothing" Then
existContact.Delete
Else
MsgBox ("Could not find the Business Contact with Full Name John Smith")
End If
Set existContact = Nothing
Set bcmContactsFldr = Nothing
Set bcmRootFolder = Nothing
Set olFolders = Nothing
Set objNS = Nothing
Set olApp = Nothing