在 Windows 7 中获取/创建 Outlook 应用程序 [英] Getting/Creating an Outlook Application in Windows 7

查看:22
本文介绍了在 Windows 7 中获取/创建 Outlook 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取当前正在运行的 Outlook 版本或启动 Outlook,以防它没有运行,但是在 Windows 7 中获取或创建 Outlook 应用程序对象时遇到了一些问题. 我认为这与 Vista 和 7 中限制性的用户权限有关.我正在使用 Outlook 2010.

这些错误仅在我已启动 Outlook 2010 实例时出现.如果没有启动Outlook,应用程序可以顺利运行(它可以自己启动一个Outlook实例).

如果有人能告诉我如何正确获取 Outlook 应用程序版本,那将非常有帮助.

我正在运行的代码是一个很长的 try-catch 块,它不断触发异常:

<代码>尝试{//创建 Outlook 的应用程序实例oApp = 新的 Microsoft.Office.Interop.Outlook.Application();}捕获(系统.异常前){尝试{//以另一种方式获取 OutlookoApp = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;}catch (System.Exception ex2){//尝试其他方式获取对象oApp = Activator.CreateInstance(Type.GetTypeFromProgID("Outlook.Application")) 作为 Microsoft.Office.Interop.Outlook.Application;}}

应用程序向我抛出以下异常:

当我尝试创建新的 Outlook 应用程序实例时:

<块引用>由于以下错误,检索具有 CLSID {0006F03A-0000-0000-C000-000000000046} 的组件的 COM 类工厂失败:80080005.

当我尝试获取 Outlook 应用实例时:

<块引用>操作不可用(来自 HRESULT 的异常:0x800401E3 (MK_E_UNAVAILABLE))

当我尝试通过 Activator 创建实例时

<块引用>由于以下错误,检索具有 CLSID {0006F03A-0000-0000-C000-000000000046} 的组件的 COM 类工厂失败:80080005.

谢谢!

解决方案

显然这些错误是因为我在不同的用户权限级别(其中一个作为管理员,另一个作为普通用户)运行 Outlook 和应用程序而触发的.

I'm trying to get the current running version of Outlook or start up Outlook in case it is not running, but I am having some issues in getting or creating the Outlook Application object in Windows 7. I think it has something to do with the user priviliges that are restrictive in Vista and 7. I am working with Outlook 2010.

edit: These errors only appear if I already have an Outlook 2010 instance started. If Outlook is not started, the application can run smoothly (it can start an Outlook instance by itself).

If anybody can tell me how to correctly get the Outlook Application version, that would be really helpful.

The code I'm running is a long try-catch block that keeps on triggering exceptions:


try
{
  // create an application instance of Outlook
  oApp = new Microsoft.Office.Interop.Outlook.Application();
}
catch(System.Exception ex)
{
  try
  {
     // get Outlook in another way
     oApp = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
  }
  catch (System.Exception ex2)
  {
     // try some other way to get the object
     oApp = Activator.CreateInstance(Type.GetTypeFromProgID("Outlook.Application")) as Microsoft.Office.Interop.Outlook.Application;
  }
}

The application throws me the following exceptions:

When I try to create a new Outlook application instance:

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

When I try to get the Outlook app instance:

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

When I try to Create an instance through the Activator

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

Thank you!

解决方案

Apparently these errors were triggered because I was running Outlook and the application on different user permission levels (one of them as administrator and the other one as regular user).

这篇关于在 Windows 7 中获取/创建 Outlook 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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