Pregunta

Estoy tratando de obtener la versión actual en ejecución de Outlook o la puesta en marcha de Outlook en caso de que no se está ejecutando , pero estoy teniendo algunos problemas en conseguir o crear el objeto de aplicación de Outlook en Windows 7 . creo que tiene algo que ver con los privilegios de usuario que son restrictivas en Vista y 7. estoy trabajando con Outlook 2010.

editar Estos errores sólo aparecen si ya tengo una instancia de Outlook 2010 comenzó. Si no se inicia Outlook, la aplicación puede funcionar sin problemas (que puede iniciar una instancia de Outlook por sí mismo).

Si alguien me puede decir cómo obtener correctamente la versión de la aplicación de Outlook, que sería de gran ayuda.

El código que estoy corriendo es un bloque try-catch tiempo que sigue provocando excepciones:


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;
  }
}

La aplicación me arroja las siguientes excepciones:

Cuando intento crear una nueva instancia de la aplicación de Outlook:

Recuperando el generador de clases COM para el componente con CLSID {0006F03A-0000-0000-C000-000000000046} fallado debido al siguiente error: 80080005.

Cuando trato de obtener la instancia de aplicación de Outlook:

Operación disponible (Excepción de HRESULT: 0x800401e3 (MK_E_UNAVAILABLE))

Cuando intento para crear una instancia a través del Activador

Recuperando el generador de clases COM para el componente con CLSID {0006F03A-0000-0000-C000-000000000046} fallado debido al siguiente error: 80080005.

Gracias!

¿Fue útil?

Solución

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).

Otros consejos

  1. In start menu select Run
  2. Type dcomcnfg and click OK
  3. Component Services window is opened.
  4. Expand the nodes Component Services -> MyComputer -> DCOM Config .
  5. Right click on the application (Outlook Message Attachment) and select properties.
  6. Click on Identity tab whatever necessary.
  7. Click on “The interactive user" then OK

It looks as if your Office installation has become corrupted.

Try to repair the installation by rerunning setup as Administrator.

It is true that if you are running a standalone application from Visual Studio or debugging from Visual Studio which use office products, you should be having same access level for both (Visual Studio and Office Products) and that is one of the reasons why this issue occurs but I am seeing online that so many people have this issue while initializing outlook object in a service. I hope what resolved the issue for me would help others too. Please follow along the steps.

  1. Go to command prompt, type the following and press enter. This opens Component Services:

    mmc comexp.msc /32

enter image description here

enter image description here

  1. Expand the nodes Component Services -> MyComputer -> DCOM Config

  2. Now find out your desired application (In this case, Outlook Message Attachment) and right click on the application (If you follow these steps, this issue related all office applications can be resolved) and select properties.

  3. Go to Identity tab and select The interactive user and press OK. This should resolve your issue.

enter image description here

The interactive user is nothing but the logged on user. When you are trying to access office products through service, the access level has to be same and that is the reason you need to specify proper user. If you want to run the service on a server without logging onto it, you need to make sure that the server has a user account which will be used for running the service as well as running office products as specified in Properties as This user (Please look at the Properties dialog box). If you want to learn about the different types of user accounts mentioned in this dialog box, please refer to the following Microsoft link.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms692541%28v=vs.85%29.aspx

In my case it was Visual Studio ran as Administrator causing the issue. When I ran it as normal user I got rid of this error finally.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top