Problem accessing ContactItems with VSTO 2005

T

timothy.goric

I'm using VSTO 2005 (C#) to try to access a public contacts folder in
Outlook which contains about 1200 contacts. Using
Microsoft.Office.Interop.Outlook.MAPIFolder, I'm looping through all
of the Items in the contacts folder and reading them as Objects, e.g.
foreach(Object obj in folder.Items). I then check which of these
Objects are a Outlook.ContactItem and proceed to get the needed
information from each.

The problem is that only about 250 of the contacts in this public
folder are being recognized as ContactItems. I can't seem to find a
way to check the type of the Objects - Object.GetType() returns
System.__ComObject, and I can't extract any more detailed information
from it.


If I try a foreach loop on the ContactItems in the Item list, e.g.
foreach(Outlook.ContactItem contact in folder.Items), I get an error
that I cannot cast a System.__ComObject to an Outlook.ContactItem.


Does anyone have any insight on this? Is there an alternate way to
access a contact's information, or possibly a way to determine what
type of Objects (besides ContactItems) I'm dealing with?
 
M

Milly Staples [MVP - Outlook]

If you repost this in an Outlook programming group, you will probably receive some useful answers as that is where the experts hang out.

--
Milly Staples [MVP - Outlook]

Post all replies to the group to keep the discussion intact. All
unsolicited mail sent to my personal account will be deleted without
reading.

After furious head scratching, (e-mail address removed) asked:

| I'm using VSTO 2005 (C#) to try to access a public contacts folder in
| Outlook which contains about 1200 contacts. Using
| Microsoft.Office.Interop.Outlook.MAPIFolder, I'm looping through all
| of the Items in the contacts folder and reading them as Objects, e.g.
| foreach(Object obj in folder.Items). I then check which of these
| Objects are a Outlook.ContactItem and proceed to get the needed
| information from each.
|
| The problem is that only about 250 of the contacts in this public
| folder are being recognized as ContactItems. I can't seem to find a
| way to check the type of the Objects - Object.GetType() returns
| System.__ComObject, and I can't extract any more detailed information
| from it.
|
|
| If I try a foreach loop on the ContactItems in the Item list, e.g.
| foreach(Outlook.ContactItem contact in folder.Items), I get an error
| that I cannot cast a System.__ComObject to an Outlook.ContactItem.
|
|
| Does anyone have any insight on this? Is there an alternate way to
| access a contact's information, or possibly a way to determine what
| type of Objects (besides ContactItems) I'm dealing with?
 

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