【问题标题】:OutLook COMException 0x800401E3 (MK_E_UNAVAILABLE)展望 COMException 0x800401E3 (MK_E_UNAVAILABLE)
【发布时间】: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,甚至都不好笑。

标签: c# outlook


【解决方案1】:

Microsoft 目前不推荐也不支持任何无人值守、非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务)的 Microsoft Office 应用程序自动化,因为 Office 可能表现出不稳定Office 在此环境中运行时出现的行为和/或死锁。

如果您要构建在服务器端上下文中运行的解决方案,您应该尝试使用已确保无人值守执行安全的组件。或者,您应该尝试找到允许至少部分代码在客户端运行的替代方案。如果您使用服务器端解决方案中的 Office 应用程序,该应用程序将缺少许多成功运行所需的功能。此外,您将承担整体解决方案稳定性的风险。在Considerations for server-side Automation of Office 文章中阅读更多相关信息。

您可以考虑在 Exchange 配置文件的情况下使用 EWS,有关详细信息,请参阅 EWS Managed API, EWS, and web services in Exchange。或者使用 Outlook 所基于的低级 API。以及围绕该 API 的任何第三方包装器 - 例如 Redemption。

【讨论】:

  • 微软可能不推荐它,但现有的 API 必须正常工作!!!
猜你喜欢
  • 2016-02-06
  • 1970-01-01
  • 1970-01-01
  • 2014-07-09
  • 1970-01-01
  • 2012-10-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多