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] = '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 上运行它?

4

1 回答 1

0

这看起来不像是 SharpDevelop 错误,看起来你只需要一个演员表。尝试这个:

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

(这是假设其中的对象filteredItems实际上是这种类型。您可能需要在分配之前测试是否是这种情况。)

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

于 2010-06-07T14:06:26.330 回答