COMException(0x800401E3):具有计划任务的操作不可用(来自HRESULT的异常:0x800401E3(MK_E_UNAVAILABLE)) [英] COMException (0x800401E3): Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)) with scheduled task

查看:353
本文介绍了COMException(0x800401E3):具有计划任务的操作不可用(来自HRESULT的异常:0x800401E3(MK_E_UNAVAILABLE))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网络上搜索失败后,这是我的问题.

After searching on the web without success, here's my question.

我有一个计划要从Outlook中检索电子邮件附件并提取数据的任务. 当我手动启动任务时,它可以正常工作,但是每当我尝试通过计划任务启动任务时,它都会失败并显示以下错误:

I've a task that i want to schedule to retrieve the attachment of an email from outlook and extract the data. It works fine when I launch the task manually but whenever I try to launch it through a scheduled task it fails with the error :

COMException(0x800401E3):操作不可用(来自HRESULT的异常:0x800401E3(MK_E_UNAVAILABLE))

COMException (0x800401E3): Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))

当程序尝试按以下方式检索或创建Outlook实例时发生:

It occurs when the program tries to retrieve or create an instance of Outlook as follow:

private Application GetApplicationObject()
    {

        Application application = null;

        if (Process.GetProcessesByName("OUTLOOK").Any())
        {
            application = Marshal.GetActiveObject("Outlook.Application") as Application;
        }
        else
        {
            application = new Application();
        }
        return application;
    }

我尝试了几种方法(批处理文件,.exe文件,程序中的参数),但都失败了. 它是使用与手动启动任务相同的帐户启动的.

I tried several ways (batch file, .exe file, parameter from a program) but they all failed. It was launched with the same account that was use to launch the task manually.

有人可以帮助我吗?任何帮助,将不胜感激! 干杯!

Can someone help me ? Any help would be appreciated! Cheers!

推荐答案

Microsoft当前不建议也不支持任何无人参与的非交互客户端应用程序或组件(包括ASP)中的Microsoft Office应用程序自动化,ASP.NET,DCOM和NT服务),因为在这种环境下运行Office时,Office可能表现出不稳定的行为和/或死锁.

如果要构建在服务器端上下文中运行的解决方案,则应尝试使用对无人值守执行安全的组件.或者,您应该尝试找到允许至少部分代码在客户端运行的替代方法.如果您使用服务器端解决方案中的Office应用程序,则该应用程序将缺少许多成功运行所需的功能.此外,您将承担整体解决方案稳定性的风险.在服务器端Office自动化注意事项一文中了解有关此内容的更多信息.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

您可以考虑使用低级API(或任何其他第三方包装程序)-Outlook所基于的扩展MAPI.如果是Exchange配置文件,则为EWS,请参见

You may consider using a low-level API (or any other third-party wrappers) - Extended MAPI on which Outlook is based on. Or EWS in case of Exchange profiles, see EWS Managed API, EWS, and web services in Exchange for more information.

这篇关于COMException(0x800401E3):具有计划任务的操作不可用(来自HRESULT的异常:0x800401E3(MK_E_UNAVAILABLE))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆