G
Guest
I'm trying to iterate though ContactItems in a public folder and am
inconsistently getting the error message "Specified cast is not valid" in the
following code (the For Each loop):
subFolder = outlookNameSpace.Folders("Public Folders").Folders("All Public
Folders").Folders("Contacts")
strCriteria = "[MessageClass]='IPM.Contact'"
myItems = subFolder.Items.Restrict(strCriteria)
For Each item As Outlook.ContactItem In myItems
Debug.WriteLine(item.FirstName)
Next
The folder contains only ContactItems and still falls over even when I add a
filter of TypeName(item) = "ContactItem".
It doesn't always crash at the same point during the iteration which leads
me to suspect that it has something to do with the synchronisation of the
public folder.
Is there any way to 'lock' a current subset of the contacts to use for this
iteration?
I'm writing this in VB.NET with Outlook 2003 and SBS 2003.
Many Thanks
Jens
inconsistently getting the error message "Specified cast is not valid" in the
following code (the For Each loop):
subFolder = outlookNameSpace.Folders("Public Folders").Folders("All Public
Folders").Folders("Contacts")
strCriteria = "[MessageClass]='IPM.Contact'"
myItems = subFolder.Items.Restrict(strCriteria)
For Each item As Outlook.ContactItem In myItems
Debug.WriteLine(item.FirstName)
Next
The folder contains only ContactItems and still falls over even when I add a
filter of TypeName(item) = "ContactItem".
It doesn't always crash at the same point during the iteration which leads
me to suspect that it has something to do with the synchronisation of the
public folder.
Is there any way to 'lock' a current subset of the contacts to use for this
iteration?
I'm writing this in VB.NET with Outlook 2003 and SBS 2003.
Many Thanks
Jens