I am trying to send an email through my ASP .NET Web application. When I run the application using LocalHost everything works fine. But when I run it on client side I receive the below mentioned error:
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
I have tried the suggestions in the forum such as grating access through 'dcomcnfg'. But of no help. I have also tried to deploy the webpage using my own NT Credentials. This also didn't help. The code snippet is shown below:
Dim app As New Application
Dim ns As [NameSpace] = app.GetNamespace("mapi")
ns.Logon("no@email.com", "password", False, True)
Dim message As MailItem = app.CreateItem(OlItemType.olMailItem)
message.To = "no@email.com"
message.Subject = "Subject"
message.Body = "Still Trying..."
message.Send()
ns.Logoff()
Any suggestions from forum?
Firstly, this has nothing to do with MAPI, neither Extended MAPI nor Simple MAPI.
Secondly, Outlook should not be used in a service (such as IIS).
You can use either
I am trying to send an email through my ASP .NET Web application. When I run the application using LocalHost everything works fine.
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
You can read more about that in the Considerations for server-side Automation of Office article.
You can BCL classes for sending emails. Or, in case of an Exchange mailbox, you can use REST API (EWS). See EWS Managed API, EWS, and web services in Exchange for more information.
User contributions licensed under CC BY-SA 3.0