Trying to automatically generate a mail message via Outlook -
Added a reference to Microsoft.Office.Interop.Outlook 14.0.0.0
It works on a Win 8/Office 2013 PC, but fails with the following exception on Win 7/Office 2010.
Code:
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
The exception is:
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)).