嘗試自動生成通過Outlook郵件消息 -的Outlook互操作異常 - 顯示新的MailItem
加入Microsoft.Office.Interop.Outlook 14.0.0.0
參考它可以在一個雙贏8 /辦公2013 PC,但失敗在Win 7 /辦公以下異常2010
代碼:
Application outlookApp = new Application();
MailItem message = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);
message.Subject = "subject";
message.Display(message);
message.HTMLBody = "body" + message.HTMLBody; //to get default signature
唯一的例外是:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
例外是給出了很多關於如何解決它的信息。你有沒有看過(TYPE_E_LIBNOTREGISTERED)? – Jonesopolis