Delete Contacts from "Contact " Folder Automatically 
Author Message
 Delete Contacts from "Contact " Folder Automatically

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



Sat, 31 Jan 2004 05:29:08 GMT  
 Delete Contacts from "Contact " Folder Automatically
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



Sat, 31 Jan 2004 05:29:13 GMT  
 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



Sun, 01 Feb 2004 20:32:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Setup "Contacts" folder as address book

2. Rename "Contacts" folder in Outlook

3. "Post" Icons in Contacts Folder

4. "Unable to Display" Contacts folder

5. CONTACTS "Unable to display the folder"

6. Outlook "Contact" folder location

7. Outlook 2002 Public Folders "contacts"

8. About "Contact" Public Folder

9. Extra "contacts" folder

10. Contacts button - want to reference shared contacts folder, not private contacts folder


 
Powered by phpBB® Forum Software © phpBB Group