关于ASP.NET网站调用Outlook发送邮件失败的问题

因为种种原因,需要调用Server上的Outlook发送email,

现在的问题是当使用VS调试时是可以正常发送email,

但是一旦部署到IIS上,WEB端调用则会提示如下错误:

异常System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)

感觉是权限哪里出现问题了,但是又不知道怎么解决,

麻烦高手帮忙指点一下。

谢谢。

智慧大石
浏览 781回答 3
3回答

青春有我

给IIS的应用程序池指定一个帐户试试

慕森王

按照您的方法给程序池指定账户结果和在web.config里节点<system.web>添加 <identity impersonate="true" userName="accountname" password="password" /> 后的执行结果一样, 提示 异常System.Runtime.InteropServices.COMException (0x80040111): Cannot create the e-mail message because a data file to send and receive messages cannot be found. Check your settings in this Microsoft Outlook profile. In Microsoft Windows, click the Start button, and then click Control Panel. Click User Accounts, and then click Mail.  Click Show Profiles, select this profile, and then click Properties. The server is not available. Contact your administrator if this condition persists.
打开App,查看更多内容
随时随地看视频慕课网APP