【发布时间】:2014-04-06 01:18:36
【问题描述】:
我正在尝试使用以下代码从用户的 Outlook 发送文件夹发送邮件。但它显示以下错误: 我的代码
try
{
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNamespace = new Outlook.NameSpace("MAPI");
Outlook.MailItem oMailItem = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMailItem.HTMLBody = bd.Trim();
oMailItem.Subject = sbj.Trim();
Outlook.Recipients oRecips = (Outlook.Recipients)oMailItem.Recipients;
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(bccadd);
oRecip.Resolve();
oMailItem.Send();
oRecip = null;
oRecips = null;
oMailItem = null;
oApp = null;
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "');</script>");
//string script = "<script>alert('" + ex.Message + "');</script>";
}
但我收到以下错误:
检索具有 CLSID 的组件的 COM 类工厂 {0006F03A-0000-0000-C000-000000000046} 由于以下原因而失败 错误:80070005 访问被拒绝。 (来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))
【问题讨论】:
-
如果我的理解是正确的,看起来你正试图在你的网络服务器上加载 Outlook 对象......仅仅因为用户在他们计算机上的浏览器上运行网站,不意味着您的 ASP.NET 代码可以在他们的计算机上使用 Outlook
-
您使用的用户帐号没有正确的用户权限
标签: c# javascript asp.net outlook