none
Outlook error Retrieving the COM class factory RRS feed

  • Question

  • 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.?
    • Moved by Youjun Tang Wednesday, May 20, 2015 9:12 AM more appropriate
    Tuesday, May 19, 2015 3:22 PM

Answers

  • hi Neha,

    As far as I know, when we automate the Outlook application the Outlook application was used by the other program like figure below:


     At this time, we were not able to get the instance for the Outlook application.

    As a workaround, we can use the preview Outlook instance to automate the application. Here is the code for your reference:

       If (Process.GetProcessesByName("OUTLOOK").Count > 0) Then
                         If objOutlook Is Nothing Then
                                  objOutlook = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)
                End If
    
                       Else
                objOutlook = New Outlook.Application()
            End If
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, May 28, 2015 6:54 AM
    Moderator

All replies

  • Hi Neha,

    As your issue is related to Outlook, I'll move your post to Outlook forum for help.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=outlookdev

    Regards,
    Youjun Tang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Youjun Tang Wednesday, May 20, 2015 9:13 AM
    Wednesday, May 20, 2015 9:12 AM
  • Hello Neha,

    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. I.e. they should be run under the same privileges. You may find the How to self-elevate an application to a high privilege level under UAC article helpful.

    Wednesday, May 20, 2015 12:19 PM
  • hi Neha,

    As far as I know, when we automate the Outlook application the Outlook application was used by the other program like figure below:


     At this time, we were not able to get the instance for the Outlook application.

    As a workaround, we can use the preview Outlook instance to automate the application. Here is the code for your reference:

       If (Process.GetProcessesByName("OUTLOOK").Count > 0) Then
                         If objOutlook Is Nothing Then
                                  objOutlook = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)
                End If
    
                       Else
                objOutlook = New Outlook.Application()
            End If
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, May 28, 2015 6:54 AM
    Moderator