When trying to open Outlook email from Web application on IIS manager get error message Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

0

My ASP.NET application has functionality that has an email button in an asp.net gridview table that when clicked on opens Microsoft Outlook email. The application code works in Visual Studio IDE. However, the error happens when the application on the IIS Manager server. I get the error message. System.Runtime.InteropServices.COMException: 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)). The code is below:

public void btnSendEmail(object sender, EventArgs e)
    {
        var email = "";
        var strSubject = "";
        var emailButton = (Control)sender;

        GridViewRow item = (GridViewRow)emailButton.NamingContainer;

        email = item.Cells[4].Text.Replace(" ", "");
        strSubject = item.Cells[1].Text.Replace(" ", "") + " " + item.Cells[2].Text.Replace(" ", "");
        if (email == "")
        {
            lblMessage.Text = "There is no email address found for attorney " + strSubject + "!";
        }
        else
        {
            Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem objMailItem = objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

            objMailItem.Subject = "Dear, " + strSubject;
            objMailItem.To = email;
            objMailItem.Display(true);
        }
    }
enter code here
c#
asp.net
outlook
asked on Stack Overflow Jan 20, 2021 by user3791368

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0