![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Using what I have learned from this group and Sue Mosher's site, I
pieced together code to delete all contacts in a contact folder from Outlook 2002 on Microsoft Exchange server. The code works good except it will only delete about half the contacts. I run it again and it deletes more contacts, and on and on until all the contacts have been deleted. I want the code to keep running until the contact folder is empty. Can anyone help me see what I have done wrong? I thank you in advance. The code follows: Sub DeleteContact() Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myContacts As Outlook.Items Dim myItems As Outlook.Items Dim myItem As Object 'Set myOlApp = CreateObject("Outlook.Application") Set myOlApp = Outlook.Application Set myNamespace = myOlApp.GetNamespace("MAPI") Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Ite ms ''Set myItems = myContacts.Restrict("[LastModificationTime] '01/1/2003'") Set myItems = myContacts 'Prompt the user for confirmation strPrompt = "Are you sure you want to delete all the contacts in the contact folder?" If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then MsgBox "This may take several minutes. Click OK to begin.", vbOKOnly For Each myItem In myItems If (myItem.Class = olContact) Then 'Debug.Print myItem.Class & "myitem.class" myItem.Delete End If Next MsgBox ("All contacts have been deleted!") End If End Sub ~Thank you, ~BJM |
Ads |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
My zip code is in the wrong position in contacts | Arlene | Outlook - Using Contacts | 4 | March 28th 07 01:19 AM |
How to delete multiple contacts through c# code | pramod | Add-ins for Outlook | 1 | December 27th 06 06:22 PM |
Exporting Contacts Code | [email protected] | Outlook - Using Contacts | 1 | June 29th 06 07:10 PM |
Telephone country code in Contacts | JW | Outlook - Using Contacts | 1 | March 15th 06 10:56 PM |
I get an error code and can't get to my contacts list | John | Outlook - Using Contacts | 0 | February 18th 06 10:41 PM |