使用 SharpDevelop 时出错
我有一些代码:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来不像是 SharpDevelop 错误,看起来你只需要一个强制转换。试试这个:(
假设
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:
(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/