我有一些代码:
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] = 'somebody@somewhare.com'";
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上运行它?
发布于 2010-06-07 22:06:26
这看起来不像是一个SharpDevelop错误,看起来您只需要一个强制转换。试试这个:
Outlook.MailItem item = (Outlook.MailItem)filteredItems[1];(假设filteredItems中的对象实际上就是这种类型。您可能想要在此赋值之前测试一下是否存在这种情况。)
此外,您还可以使用Visual Studio2010Express- http://www.microsoft.com/express/
https://stackoverflow.com/questions/2990016
复制相似问题