manjunath cv

I am trying to sync Outlook Contacts with Oracle server using C# programming. I am able to read Outlook Contacts, but unable to read Outlook Distribution lists. Whenever the program
tried to read a distribution list, it is giving us the following exception


[System.InvalidCastException] = {"Unable to cast COM object of type 'System.__ComObject' to interface type 'Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063021-0000-0000-C000-000000000046}


Also it is not reading the contacts that are present after the distribution list. It is terminating the application.


Can someone please give me a sample code or hint on how to solve this problem.








Re: Visual Studio Tools for Office Unable to read distribution lists in Outlook using C# programming.

X4U

HI,

a distributionlist is not a ContactItem - it's a DistListItem Item.

You can do this this way:

Outlook.DistListItem distList = item as Outlook.DistListItem;

if (distList != null) // we have a dist list

Outlook.ContactItem contact as Outlook.ContactItem;

if (contact != null) // we have a contact item.

Hope this helps,

greets, Helmut