Outlook: contactitem loop failed

M

Murielle

After many tries I seem to have failed in putting the code together to
loop
through all contacts. The first 249 elements are VarType = string (8)
then object (9) WHY ?? -> error on line
"objContact.ItemProperties.Item() ???

In folder 'Public Folders/All Public Folders/So Applications/Pre So
Group' exist 2100 contactitems -> all TypeName are correct =
"ContactItems"


Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objMAPIFolder As Outlook.MAPIFolder
Dim objAllContacts As Outlook.Items
Dim objContacts As Outlook.Items
Dim objContact As Outlook.ContactItems

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objMAPIFolder = objNS.Folders("Public Folders")
Set objMAPIFolder = objNS.Folders("All Public Folders")
Set objMAPIFolder = objNS.Folders("So Applications")
Set objMAPIFolder = objNS.Folders("Pre So Group")

Set objAllContacts = objMAPIFolder.Items
objAllContacts.Sort "[FullName]", False
objAllContacts.IncludeRecurrences = True

sFilter = "[MessageClass]= 'IPM.Contact.Pre So Group'"
Set objContacts = objAllContacts.Restrict(sFilter)

lngCount = objContacts.Count

For lngCounter = lngCount To 1 Step - 1

Set objContact = objContacts(lngCounter)

' User properties -> fout
strFDirector = objContract.ItemProperties.Item("FDirector")

Set objContact = Nothing

Next

Set objContacts = Nothing
Set objAllContacts = Nothing
Set objMAPIFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing


Before I pull all of my hair out could someone fill in the gaps!

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top