因为种种原因,需要调用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)
感觉是权限哪里出现问题了,但是又不知道怎么解决,
麻烦高手帮忙指点一下。
谢谢。
最后还是权限有问题,
自己解决办法参照如下:http://www.cnblogs.com/allenfly/p/6647164.html
给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.