Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > EXCHANGE SERVER (TECHNET) > Exception occured when retrieving ContactItem in olFolderContacts
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 20th November 01:23
octopusthu
External User
 
Posts: 1
Default 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?
  Reply With Quote


  sponsored links


2 20th November 01:24
ken slovak - mvp - outlook
External User
 
Posts: 1
Default 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
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666