使用 SharpDevelop 时出错

发布于 2024-09-04 04:30:01 字数 819 浏览 1 评论 0原文

我有一些代码:

Outlook.Application outLookApp = new Outlook.Application();
Outlook.Inspector inspector = outLookApp.ActiveInspector();
Outlook.NameSpace nameSpace = outLookApp.GetNamespace("MAPI");
Outlook.MAPIFolder inbox = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
String sCriteria = "[SenderEmailAddress] = '[email protected]'";
Outlook.Items filteredItems = inbox.Items.Restrict(sCriteria);
// totaly sure that count > 0;
Outlook.MailItem item = filteredItems[1];

在最后一行我有错误:“无法将类型'object'隐式转换为'Microsoft.Office.Interop.Outlook.MailItem'。存在显式转换(您是否缺少转换?)”。我不知道为什么。以前我使用了 VisualStudio 2010,但我的试用版已过期。有希望在 SharpDevelop 上运行它吗?

I have some code:

Outlook.Application outLookApp = new Outlook.Application();
Outlook.Inspector inspector = outLookApp.ActiveInspector();
Outlook.NameSpace nameSpace = outLookApp.GetNamespace("MAPI");
Outlook.MAPIFolder inbox = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
String sCriteria = "[SenderEmailAddress] = '[email protected]'";
Outlook.Items filteredItems = inbox.Items.Restrict(sCriteria);
// totaly sure that count > 0;
Outlook.MailItem item = filteredItems[1];

In the last line I have error: "Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Outlook.MailItem'. An explicit conversion exists (are you missing a cast?)". I don't know why. Previous I used VisualStudio 2010 but my trial has expired. Is there any hope to run this on SharpDevelop?

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

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

发布评论

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

评论(1

千仐 2024-09-11 04:30:01

这看起来不像是 SharpDevelop 错误,看起来你只需要一个强制转换。试试这个:(

Outlook.MailItem item = (Outlook.MailItem)filteredItems[1];

假设 filteredItems 中的对象实际上属于这种类型。您可能想在分配之前测试一下是否是这种情况。)

此外,您可以使用 Visual Studio 2010 Express - http://www.microsoft.com/express/

This doesn't look like a SharpDevelop error, it looks like you just need a cast. Try this:

Outlook.MailItem item = (Outlook.MailItem)filteredItems[1];

(this is assuming that the objects in filteredItems are actually of this type. You may want to test if this is the case before this assignment.)

Also, you could use Visual Studio 2010 Express - http://www.microsoft.com/express/

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