Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi I am working on C# application in which i am trying to read the mails from the Outlook Inbox.
I am using VS2010 and MS-Office 2007, I have added the refernce in the visual studio, The application is working fine in my system, but when i run the same application in client system, its throwing COM exception,
The exception message is like this
Unable to cast COM object of type System_ComObject to InterfaceType “Microsoft.Office.Interop.Outlook.MailItem” . This operation failed because the QueryInterface Call on the Com Component for the Interface with ID………..

I tested in 3 to 4 systems in which VS2010 is installed, and the client system in which its throwing exception doesnt contain vs2010 in it, but .net 4.0 framework,ms-office 2007 is installed in client system.

what may be the error ?
Any suggestions plz ..
Thanks in advance..
Posted
Comments
Richard MacCutchan 11-Nov-13 4:12am    
Why have you not included the full text of the error message?
sameer549 11-Nov-13 4:31am    
Error Message :

Unable to cast COM object of type System_ComObject to InterfaceType “Microsoft.Office.Interop.Outlook.MailItem” . This operation failed because the QueryInterface Call on the Com Component for the Interface with ID’{00063034-0000-0000-C000-00000000046} failed due to the following error. No such interface supported (Exception from HRESULT: 0x80004002)
(E_NONINTERFACE)
Richard MacCutchan 11-Nov-13 4:38am    
OK, so look at your code where the error occurs and it will tell you which interface you are trying to access. That will then show what software component is not present on the system in question.
sameer549 11-Nov-13 4:53am    
Hi richard, thanks fr ur reply
I am getting exception while trying to access MailItem ex code :
subject = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).Subject;

can i know what will be the reason for this exception ??
Richard MacCutchan 11-Nov-13 5:01am    
Well I cannot tell you anything more than the information provided in that message. The interface ID does not exist, so some component is not installed on the computer in question.

Obviously you try to instantiate an object with a version contained in Office 2010. You must not expect Office 2007 to have that in the same version!
Rather expect Office 2010 to be capable to work with Interop libraries of Office 2007. And that's the way to go: build your application with support for Office 2007.
 
Share this answer
 
Comments
sameer549 12-Nov-13 0:02am    
Hi Bernhard, we are using office 2007 only both in my system and client system .
This might help you -> Install Office Runtime Redistributable.
http://msdn.microsoft.com/en-us/library/ms178739.aspx[^]
 
Share this answer
 
Thanks for your replies. I solved this.

Actually the exception is because, The outlook contains not only mail items but also calender items,meeting items etc,. hence it is throwing exception when we are trying to access other item as mailItem.


click here for solution
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900