0
votes

We have a functionality to add contacts to outlook.

I simply want to do it to existing outlook process if one is running or open if not running.

I get error:

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).in case the process in not already running.

Note: the below method is called 2 times.

My code is:

Private Sub InitObject()
    If (Process.GetProcessesByName("OUTLOOK").Count > 0) Then
        objOutlook = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)
        'If objOutlook Is Nothing Then
    Else
        objOutlook = New Outlook.Application()
    End If
    If objNamespace Is Nothing Then
        objNamespace = objOutlook.GetNamespace("MAPI")
        objNamespace.Logon("", "", False, False)
    End If

    If objFolder Is Nothing Then
        objFolder = objNamespace.GetDefaultFolder(10)
    End If
End Sub

I read several posts on this saying admin privileges and all. Now I am running Visual Studio without Admin rights. I am sacred is this error will be seen in production too where we don't use Visual Studio?

1

1 Answers

0
votes

What Outlook version do you have installed on the problematic PC? Is it the Click2Run edition of Outlook 2010?

Anyway, I see two possible causes for that:

  1. You have got the Click2Run edition of Office 2010 installed on the PC. The fact is that the Click2Run edition of Office 2010 doesn't support automation. See Office 2010 Click-to-Run compatibility with add-ins for more information. Also you may find the How to: Verify Whether Outlook Is a Click-to-Run Application on a Computer article.
  2. Your program and MS Outlook must both be run as administrator or as normal privilege level. They should be under the same privileges. You may find the How to self-elevate an application to a high privilege level under UAC article helpful.

Be aware, Outlook is a singleton. I.e. if it is already running, you will get a pointer to the already running instance when you create a new Outlook Application instance.