I'm trying to create a script that will delete contacts that have a specific email address. The script below works, but it deletes all contacts in the contact list. Thanks!
Code:
Sub DeleteContacts()
Dim myOutlook As Outlook.Application
Dim myInformation As NameSpace
Dim myContacts As Items
Dim i As Long
Dim lngCount As Long
Set myOutlook = CreateObject("Outlook.Application")
Set myInformation = myOutlook.GetNamespace("MAPI")
Set myContacts = myInformation.GetDefaultFolder(olFolderContacts).Items
lngCount = myContacts.Count
For i = lngCount To 1 Step -1
myContacts(i).Delete
Next
End Sub