![]() |
Exception occured when retrieving ContactItem in olFolderContacts
I'm using the following code to try to retrieve ContactItems in Outlook:
Outlook.MAPIFolder defaultFolder = applicationObject.GetNamespace ("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders .olFolderContacts); foreach (Outlook.ContactItem item in defaultFolder.Items) { //codes...... } However, there are also DistListItem in the same folder and the following exception occured: System.InvalidCastException: Unable to cast COM object of type 'System._ComObject' to interface type 'Microsoflt.Office.Interop.Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID ...... Is there another way other than 'foreach' clause that I can get the ContactItem or DistListItem in a Outlook folder? |
Exception occured when retrieving ContactItem in olFolderContacts
Your post was already answered in another group you posted in. Please do not
post in multiple groups and look for responses to your original post. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "OctopusThu" wrote in message ... I'm using the following code to try to retrieve ContactItems in Outlook: Outlook.MAPIFolder defaultFolder = applicationObject.GetNamespace ("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders .olFolderContacts); foreach (Outlook.ContactItem item in defaultFolder.Items) { //codes...... } However, there are also DistListItem in the same folder and the following exception occured: System.InvalidCastException: Unable to cast COM object of type 'System._ComObject' to interface type 'Microsoflt.Office.Interop.Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID ...... Is there another way other than 'foreach' clause that I can get the ContactItem or DistListItem in a Outlook folder? |
All times are GMT +1. The time now is 07:57 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com