I am developing a windows application, which sends email using outlook.I have the following Dll's referenced in my application. Microsoft.Office.Core, Microsoft.Office.Interop.Outlook,Microsoft.Office.Tools.Outlook,, Microsoft.Office.Tools.Outlook.v40.Utilities.
I have the following code
Outlook.Application app = new Outlook.Application();
Outlook.MailItem newMail =
(Outlook.MailItem)app.CreateItem(Outlook.OlItemType.olMailItem);
which creates the Outlook application and MailItem objects.
When I run this application on my local machine which has Outlook installed i see that the mails are being sent without any issues.
But when I deployed this application on a production machine which does not have Outlook installed the Email sent is failing with the below exception.
ERROR: Failed to send mail: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Do I need to register any dlls on the production machines to make it work? or Do I need to install Outlook as well on the production machine?
If I need to register any dlls or COM objects, what is the procedure for doing so on the production machines using the setup project.
The Interop dll's are just that: they allow .NET code to call COM objects by translating between the .NET and COM objects. You need the full Outlook client installed (the Office licence does not allow just some of the dll's to be installed even if you can work out which one's you need, and all the ones that need in turn etc).
At one company I worked for, they would not allow Office apps to be installed on servers (that might also be due to licencing restrictions). If this is the case, then the best bet is to send EMail from .Net via SMTP.
User contributions licensed under CC BY-SA 3.0