• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Delete contacts in Outlook 2007

B
#1
Hi All,

Please let me know the correct group if this is in the wrong place.

I am trying to delete all Outlook contacts in a folder.

For some reason, the following code deletes exactly half of the contacts in
the folder. Can someone see what I'm doing incorrectly?


OutLook._Application outlookObj = new OutLook.Application();
OutLook.MAPIFolder fldContacts =
(OutLook.MAPIFolder)outlookObj.Session.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);

foreach (Microsoft.Office.Interop.Outlook._ContactItem contactItem in
fldContacts.Items)
{
contactItem.Delete();
}
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)