获取 Outlook 2007 邮件内容时出错

发布于 2024-10-19 01:44:45 字数 737 浏览 2 评论 0原文

我目前正在制作一个程序,需要分析outlook 2007和outlook 2010中的邮件消息。

在安装了office套件的机器上,它工作没有问题。如果他们只有 Outlook,则似乎无法获取邮件消息,当我尝试获取文档的内容时,它会出现以下错误:

"Unable to cast COM object of type 
'Microsoft.Office.Interop.Word.DocumentClass' to interface type
'Microsoft.Office.Interop.Word._Document'. This operation failed because the 
QueryInterface call on the COM component for the interface with IID '{0002096B-0000-
0000-C000-000000000046}' failed due to the following error: No such interface supported    
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

这是我用来获取消息的代码:

Office.Word.Document document = inspector.WordEditor as Office.Word.Document;
string body = document.Content.Text;

I'm currently making a program that needs to analyze the mail message in outlook 2007 and outlook 2010.

On machines that have the office suite installed, it works no problem. If they only have outlook, it doesn't seem to be able to get the mail message and when I try to get the content of the document, it gives me the following error:

"Unable to cast COM object of type 
'Microsoft.Office.Interop.Word.DocumentClass' to interface type
'Microsoft.Office.Interop.Word._Document'. This operation failed because the 
QueryInterface call on the COM component for the interface with IID '{0002096B-0000-
0000-C000-000000000046}' failed due to the following error: No such interface supported    
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

This is the code I'm using to get the message:

Office.Word.Document document = inspector.WordEditor as Office.Word.Document;
string body = document.Content.Text;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美胚控场 2024-10-26 01:44:46

据我所知,您应该将其投射到 如果您要查看邮件,则 MailItem 不是 Word 文档。 MailItem 对象有一个名为 Body (以及关联的 BodyFormat )。

另外,@StackOverflowException是正确的,在开始操作它之前始终检查该项目是否不为空。这将告诉您它是否是您认为的类型。

To my knowledge, you should be casting it to a MailItem not a word document if you're going after the message. Off the MailItem object is a property called Body (and an associated BodyFormat).

Also, @StackOverflowException is correct, always check if the item is not null before you begin to manipulate it. This will tell you if it is or isn't the type you think it is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文