A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Exception occured when retrieving ContactItem in olFolderContacts



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old November 9th 06, 05:56 AM posted to microsoft.public.outlook.program_forms
OctopusThu
external usenet poster
 
Posts: 25
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?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


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-2025 Outlook Banter.
The comments are property of their posters.