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
User contributions licensed under CC BY-SA 3.0