C
Céline Brien
Hi everybody,
I am trying to delete contacts by categorie. See codes below.
No message, no nothing. It just don't work.
Can you help ?
Many thanks,
Céline
-------------------------------------------------------------------
Sub DeleteOutlookContacts()
On Error Resume Next
Dim StrContacts As String
Dim OlApp As New Outlook.Application
Dim OlMapi As Outlook.NameSpace
Dim OlFolder As Outlook.MAPIFolder
Dim OlItems As Outlook.Items
Dim OlContact As Outlook.ContactItem
Set OlMapi = OlApp.GetNamespace("MAPI")
Set OlFolder = OlMapi.GetDefaultFolder(olFolderContacts)
Set OlItems = OlFolder.Items
For Each OlContact In OlItems
If OlContact.Categories = "Excel" Then
OlContact.Delete
End If
Next OlContact
MsgBox StrContacts
Set OlContact = Nothing
Set OlItems = Nothing
Set OlFolder = Nothing
Set OlMapi = Nothing
Set OlApp = Nothing
End Sub
I am trying to delete contacts by categorie. See codes below.
No message, no nothing. It just don't work.
Can you help ?
Many thanks,
Céline
-------------------------------------------------------------------
Sub DeleteOutlookContacts()
On Error Resume Next
Dim StrContacts As String
Dim OlApp As New Outlook.Application
Dim OlMapi As Outlook.NameSpace
Dim OlFolder As Outlook.MAPIFolder
Dim OlItems As Outlook.Items
Dim OlContact As Outlook.ContactItem
Set OlMapi = OlApp.GetNamespace("MAPI")
Set OlFolder = OlMapi.GetDefaultFolder(olFolderContacts)
Set OlItems = OlFolder.Items
For Each OlContact In OlItems
If OlContact.Categories = "Excel" Then
OlContact.Delete
End If
Next OlContact
MsgBox StrContacts
Set OlContact = Nothing
Set OlItems = Nothing
Set OlFolder = Nothing
Set OlMapi = Nothing
Set OlApp = Nothing
End Sub