![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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? |
#2
|
|||
|
|||
![]()
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? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ContactItem.Save() | Virda | Outlook and VBA | 9 | January 10th 07 11:27 AM |
Exception, error retrieving COM class factory... | [email protected] | Add-ins for Outlook | 0 | June 22nd 06 12:23 PM |
Why does it keep tell me an error has occured when importing exl? | ABY | Outlook - General Queries | 0 | February 23rd 06 09:22 PM |
New ContactItem with same EntryID | jim | Add-ins for Outlook | 3 | January 20th 06 07:01 PM |
What makes a ContactItem unique | jim | Add-ins for Outlook | 1 | January 19th 06 03:14 PM |