由于以下错误,检索组件的COM类工厂失败:80040154.'

时间:2014-10-31 15:17:49

标签: c# vb.net outlook

我有一个使用outlook dll的Asp.net网站。 我使用以下代码

    Dim app As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application
    Dim mailitem As Microsoft.Office.Interop.Outlook._MailItem = app.CreateItem(OlItemType.olMailItem)
    mailitem.To = legRev
    mailitem.CC = cc
    mailitem.Subject = Subject
    mailitem.HTMLBody = "Hi, <br/>"
    mailitem.HTMLBody += "<br/> The Deal - " + ClientName + ", has been Assigned to you for Legal Review. <br/><br/>"
    mailitem.HTMLBody += "Expected Signature Date : " + SignDate + " <br/>"
    mailitem.HTMLBody += "Customer Funding Date   : " + FundingDate + " <br/>"
    mailitem.HTMLBody += "Financed Amount   : " + sFinancedAmount + " <br/><br/>"
    mailitem.HTMLBody += "Please, click here to provide your final approval. <br/><br/>"
    If innerCC.Length = 0 Then
        mailitem.HTMLBody += "<a href=mailto:" + innerTo + "?Subject=" + innerSubject + ">" + PathName + "</a>"
    Else
        mailitem.HTMLBody += "<a href=mailto:" + innerTo + "?CC=" + innerCC + "&Subject=" + innerSubject + ">" + PathName + "</a>"
    End If

    mailitem.Display(False)

当我运行代码时,我收到类似的错误,&#39;由于以下错误,检索到具有CLSID {0006F03A-0000-0000-C000-000000000046}的组件的COM类工厂失败:80040154。&# 39;

我没有安装Outlook。但我已将interop.outlook dll复制到我的GAC。

请帮忙

1 个答案:

答案 0 :(得分:1)

首先,不应在服务中使用Office应用程序(包括Outlook),例如IIS。 其次,interop.outlook dll只不过是一个美化的头文件。您实际上需要安装Outlook才能使用它。