Hallo zusammen,
ich habe ein Problem. Ich will mit einem VB6 Programm alle Kontakte in Outlook-Kontaktordner löschen. Doch mit dem Code den ich habe, löscht es mir nur jeden 2. Kontakt. Weiss jemand, wo der Fehler liegen könnte?
Der Code:
Dim olAppl As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olMAPIFolder As Outlook.MAPIFolder
Dim olItems As Outlook.Items
Dim olResItems As Outlook.Items
Dim olContact As Outlook.ContactItem
Dim sFilter As String
Private Sub Command1_Click()
Set olAppl = CreateObject("Outlook.Application.10")
Set olNS = olAppl.GetNamespace("MAPI")
Set olMAPIFolder = olNS.GetDefaultFolder(olFolderContacts)
Set olItems = olMAPIFolder.Folders.Item("MeineKontakte").Items
sFilter = "[MessageClass] = 'IPM.Contact'"
Set olResItems = olItems.Restrict(sFilter)
For Each olContact In olResItems
olContact.Delete
Next olContact
Set olResItems = Nothing
Set olItems = Nothing
Set olMAPIFolder = Nothing
Set olNS = Nothing
Set olAppl = Nothing
MsgBox "Alle Kontakte gelöscht"
End Sub
ich habe ein Problem. Ich will mit einem VB6 Programm alle Kontakte in Outlook-Kontaktordner löschen. Doch mit dem Code den ich habe, löscht es mir nur jeden 2. Kontakt. Weiss jemand, wo der Fehler liegen könnte?
Der Code:
Dim olAppl As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olMAPIFolder As Outlook.MAPIFolder
Dim olItems As Outlook.Items
Dim olResItems As Outlook.Items
Dim olContact As Outlook.ContactItem
Dim sFilter As String
Private Sub Command1_Click()
Set olAppl = CreateObject("Outlook.Application.10")
Set olNS = olAppl.GetNamespace("MAPI")
Set olMAPIFolder = olNS.GetDefaultFolder(olFolderContacts)
Set olItems = olMAPIFolder.Folders.Item("MeineKontakte").Items
sFilter = "[MessageClass] = 'IPM.Contact'"
Set olResItems = olItems.Restrict(sFilter)
For Each olContact In olResItems
olContact.Delete
Next olContact
Set olResItems = Nothing
Set olItems = Nothing
Set olMAPIFolder = Nothing
Set olNS = Nothing
Set olAppl = Nothing
MsgBox "Alle Kontakte gelöscht"
End Sub