Search

Sunday, March 16, 2008

Unable to read distribution lists in Outlook MAPI using C# programming.

Are you having problem reading distribution list in outlook using c# .Net framework ? While reading a distribution list you might get the below error i solved this problem after searching few sites

[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}

You may find unable to read the contacts that are present after the distribution list. It is terminating the application.

Solution:

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.

0 comments:

Post a Comment

Other Interesting Articles



Related Article Widget by Yogith

Search Powered by Google