【发布时间】:2015-09-23 15:04:14
【问题描述】:
我正在尝试一个 ASP.NET 应用程序,但我遇到了 OutLook 问题。
后面的代码:
public Outlook()
{
// Check whether there is an Outlook process running.
if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
{
// If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
OutlookApplication = Marshal.GetActiveObject("Outlook.Application") as Application;
}
else
{
// If not, create a new instance of Outlook and log on to the default profile.
OutlookApplication = new Application();
NameSpace nameSpace = OutlookApplication.GetNamespace("MAPI");
nameSpace.Logon("", "", missing, missing);
nameSpace = null;
}
}
}
当我玩应用程序时:
System.Runtime.InteropServices.COMException (0x800401E3): Opération non >disponible (Exception de HRESULT : 0x800401E3 (MK_E_UNAVAILABLE))
我已经读过了:
我猜想您是以管理员身份运行 Visual Studio(通过以管理员身份运行启动),而 Outlook 以用户身份打开,该用户以 Windows 登录身份登录。所以 Visual Studio 运行在与 Outlook 客户端不同的用户下。
但我不知道如何解决它。
【问题讨论】:
-
再说一次,这不是asp-classic,甚至都不好笑。