在 VS 2010 中开发的通过 MS Outlook 2010 发送电子邮件的 c# 代码完美运行:
1. using Outlook = Microsoft.Office.Interop.Outlook;
...
2. Outlook.Application outlookApp = new Outlook.Application();
3. Outlook.MailItem mail = outlookApp.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
...
在另一台装有 MS Outlook 2013 的电脑上使用此程序时:第 3 行出现以下错误:
无法将类型为“Microsoft.Office.Interop.Oulook.ApplicationClass”的 COM 对象转换为接口类型“Microsoft.Office.Interop.Oulook._Application”。此操作失败,因为 IID 为“{00063001-0000-0000-C000-000000000046}”的接口的 COM 组件上的 QueryInterface 调用因以下错误而失败:不支持此类接口(来自 HRESULT 的异常:0x80004002 (E_NOINTERFACE)) .
删除 Outlook 互操作参考并在 VS 2013 中添加最新版本 15 无济于事。如何使用 Outlook 2013 发送邮件?是否可以使用具有相同代码的 Outlook 2010?