Outlook dll在发送电子邮件时遇到的问题 [英] Issues with Outlook dlls when sending emails
问题描述
我正在使用Microsoft.Office.Interop.Outlook从C#应用程序发送电子邮件,因为我的组织中不允许SMTPClient发送电子邮件。当我在本地计算机上运行时,它工作正常。但是当我在服务器中托管应用程序时,它给出错误检索CLSID {0006F03A-0000-0000-C000-000000000046}的组件的COM类工厂由于以下错误而失败:80080005 。请看下面我使用过的代码片段。
Hi,
I am using Microsoft.Office.Interop.Outlook to send emails from a C# application since SMTPClient is not allowed in my organization to send emails.When i run this in my local machine,it is working fine.But when i hosted the application in the server,it is giving error "Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005". please see the code snippet below which I have used.
using Outlook = Microsoft.Office.Interop.Outlook;
.
.
.
string HTMLBody = "";
Outlook.Application oApp = new Outlook.Application()
// Get the NameSpace and Logon information.
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// Log on by using a dialog box to choose the profile.
oNS.Logon(Missing.Value, Missing.Value, true, true);
// Create a new mail item.
Outlook.MailItem mail = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
HTMLBody = File.ReadAllText("D:\\TLDR_VacationPlanner\\Email emplates\\VacationTemplate.html");
mail.To = strEmail;
mail.HTMLBody = HTMLBody;
mail.Send();
oNS.Logoff();
//oRecip = null;
mail = null;
oNS = null;
oApp = null;
我已复制并注册服务器中的dll使用Regasm.Please建议。
谢谢。
I have copied and registered the dlls in the server using Regasm.Please advise.
Thanks.
推荐答案
这篇关于Outlook dll在发送电子邮件时遇到的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!