J
John
Hi
I am trying to delete contacts based on a condition via code. I am using the
below code. It is vb.net so syntax is slightly different than vba.
O = New Outlook.Application
F = O.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
For I = 1 To ICount
oContact = DirectCast(F.Items.Item(I),
Outlook.ContactItem)
If InStr(oContact.Categories, "Clients") <> 0 then
oContact.Delete()
End If
Next I
The problem is that not all contacts are deleted. Presumably because when a
contact is deleted, F.Items.Item(I) does not mean anymore what it should.
Can someone tell me how can I reliably delete all contacts that fall into
the condition via code?
Thanks
Regards
I am trying to delete contacts based on a condition via code. I am using the
below code. It is vb.net so syntax is slightly different than vba.
O = New Outlook.Application
F = O.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
For I = 1 To ICount
oContact = DirectCast(F.Items.Item(I),
Outlook.ContactItem)
If InStr(oContact.Categories, "Clients") <> 0 then
oContact.Delete()
End If
Next I
The problem is that not all contacts are deleted. Presumably because when a
contact is deleted, F.Items.Item(I) does not mean anymore what it should.
Can someone tell me how can I reliably delete all contacts that fall into
the condition via code?
Thanks
Regards