
Delete Contacts from "Contact " Folder Automatically
The contacts are in the folder's Items collection. Loop through that,
counting down from Count:
Set olContactsHistItems = olContactsFolder.Folders.("History").Items
For i = olContactsHistItems.Count To 1 Step -1
olContactsHistItems.Items(i).Delete
Next i
--
Sue Mosher, Outlook MVP
Author of
Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours
Microsoft Outlook 2000 E-mail and Fax Guide
Outlook and Exchange solutions at http://www.slipstick.com
Quote:
> I need a command/vba code to "delete" all contacts within
> the contacts folder in my personal Outlook folder. I tried
> the code below and it deleted the folder itself including
> the contacts. I just want to delete the contacts. Thanks!
> Set mapiNamespace = Application.GetNamespace("MAPI")
> Set olContactsFolder = mapiNamespace.GetDefaultFolder
> (olFolderContacts)
> Set olContactsHistItems = olContactsFolder.Folders.Item
> ("History")
> olContactsHistItems.Delete