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} a distributionlist is not a ContactItem - it's a DistListItem Item. You can do this this way: if (distList != null) // we have a dist list Outlook.ContactItem contact as Outlook.ContactItem; if (contact != null) // we have a contact item.
You may find unable to read the contacts that are present after the distribution list. It is terminating the application.
Solution:
Outlook.DistListItem distList = item as Outlook.DistListItem;
0 comments:
Post a Comment