在Outlook中访问MailItem时出现异常 [英] Com Exception While Accessing MailItem in Outlook

查看:174
本文介绍了在Outlook中访问MailItem时出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用C#应用程序,我正在尝试从Outlook收件箱中读取邮件。

我使用VS2010和MS-Office 2007,我在视觉中添加了引用工作室,应用程序在我的系统中工作正常,但是当我在客户端系统中运行相同的应用程序时,它抛出COM异常,

异常消息是这样的

< b>无法将System_ComObject类型的COM对象强制转换为InterfaceTypeMicrosoft.Office.Interop.Outlook.MailItem。此操作失败,因为带有ID的接口的Com组件上的QueryInterface调用............



我在3到4个系统中测试过VS2010已安装,其抛出异常的客户端系统中不包含vs2010,但.net 4.0框架,ms-office 2007安装在客户端系统中。



可能是什么错误?

任何建议PLZ ..

在此先感谢..

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..

推荐答案

显然,您尝试使用Office 2010中包含的版本实例化对象。您不能指望Office 2007在同一版本中具有该版本!

相当期望Office 2010能够与Office 2007的Interop库一起工作。这就是要走的路:构建支持Office 2007的应用程序。
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.


这可能对您有所帮助 - >安装Office Runtime Redistributable。

http://msdn.microsoft.com/en -us / library / ms178739.aspx [ ^ ]
This might help you -> Install Office Runtime Redistributable.
http://msdn.microsoft.com/en-us/library/ms178739.aspx[^]


感谢您的回复。我解决了这个问题。



实际上,例外是因为,Outlook不仅包含邮件物品,还包含日历物品,会议物品等。因此,当我们尝试访问其他项目为mailItem时,它会抛出异常。





点击此处获取解决方案
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


这篇关于在Outlook中访问MailItem时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆