none
Can't set Outlook.Application object - RRS feed

  • Question

  • I am trying to retrieve the namespace object for the current Outlook application session.  Code as follows:

    I am getting the following error when calling GetNamespace for "MAPI".  Can anyone help with this?

    Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

    Running Outlook 2010, VS2010, Win7

    Thanks

    Dim olApp as New Outlook.Application

    olApp = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)

    Dim olNS As Outlook.NameSpace
    olNS = olApp.Application.GetNamespace(
    "MAPI")



    • Edited by chltn07 Tuesday, December 20, 2011 4:01 PM
    Monday, December 19, 2011 7:13 PM

Answers

  • Okay, so I have been able to resolve the problem and work with the MAPI folders and stores as needed: 

    1. Using VS2010 64bit and Office 2010 64bit - System had VS2010 64bit installed after 32bit version of Office 2010 was installed.  Installed Office 2010 64bit. 

    2. Consistant in the use of .Net framework version - be sure all projects in the solution have Advance Compile settings have the same Target Framework.  In my case all were set to .Net 3.5.

    These two steps seemed to resolve the version conflicts for mccorlib.dll and msoutl.olb when running this piece of code:

    Dim olApp as New Outlook.Application

    olApp = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)

    Dim olNS As Outlook.NameSpace
    olNS = olApp.Application.GetNamespace(
    "MAPI")

    I am not entirely sure if this helped but I found a version of mscorlib.dll as part of the Siverlight installation (in the folder).  I uninstalled Silverlight before upgrading the Office 2010 to 64bit.  Silverlight was reinstalled later as part of corporate SCCM pushes.  The problem was still resolved.  I have now been able to create a library of functions for working with the MAPI stores and folders that have passed unit testing.

    I hope this will be helpful to anyone else having this problem. 

    • Edited by chltn07 Monday, January 9, 2012 3:44 PM
    • Marked as answer by chltn07 Monday, January 9, 2012 4:39 PM
    Monday, January 9, 2012 2:47 PM

All replies

  • Hello,

    Try this code:

    Dim olApp as New Outlook.Application
    Dim olNS As Outlook.NameSpace = olApp.Sesssion
    

    Do you create an Outlook add-in or a standalone application?


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader
    Monday, December 19, 2011 7:35 PM
  • I am creating a standalone app.  I am trying to enumerate through the stores in the namespace to use a specific store by name.  I had this running in a VB6 app using MAPI that I need to convert over to VB.net and Office2010 (64bit).  First thing I am trying to do is to simply get the name of each store and the folders in that store in the current OUtlook MAPI namespace        

    The namespace object (olNS) is note being created so there are not any stores. What am I missing? 

            Dim colStores As Outlook.Stores
            Dim oStore As Outlook.Store
            Dim olFolder As Outlook.Folder

            Dim olApp As New Outlook.Application
            Dim olNS As Outlook.NameSpace = olApp.Sesssion
            colStores = olNS.Stores 
            For Each oStore In colStores
                Debug.Print(oStore.DisplayName.ToString)
                For Each olFolder In oStore.Folders
                     Debug.Print(olFolder.FolderPath.ToString)

                Next
            Next

    Thanks

     I am getting an error when attempting to create the namespace object:

    System.MissingMemberException was unhandled by user code
      Message=Public member 'Sesssion' on type 'ApplicationClass' not found.
      Source=Microsoft.VisualBasic
      StackTrace:
           at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
           at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
     

    • Edited by chltn07 Tuesday, December 20, 2011 4:15 PM
    Tuesday, December 20, 2011 3:40 PM
  • Okay, so I have been able to resolve the problem and work with the MAPI folders and stores as needed: 

    1. Using VS2010 64bit and Office 2010 64bit - System had VS2010 64bit installed after 32bit version of Office 2010 was installed.  Installed Office 2010 64bit. 

    2. Consistant in the use of .Net framework version - be sure all projects in the solution have Advance Compile settings have the same Target Framework.  In my case all were set to .Net 3.5.

    These two steps seemed to resolve the version conflicts for mccorlib.dll and msoutl.olb when running this piece of code:

    Dim olApp as New Outlook.Application

    olApp = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)

    Dim olNS As Outlook.NameSpace
    olNS = olApp.Application.GetNamespace(
    "MAPI")

    I am not entirely sure if this helped but I found a version of mscorlib.dll as part of the Siverlight installation (in the folder).  I uninstalled Silverlight before upgrading the Office 2010 to 64bit.  Silverlight was reinstalled later as part of corporate SCCM pushes.  The problem was still resolved.  I have now been able to create a library of functions for working with the MAPI stores and folders that have passed unit testing.

    I hope this will be helpful to anyone else having this problem. 

    • Edited by chltn07 Monday, January 9, 2012 3:44 PM
    • Marked as answer by chltn07 Monday, January 9, 2012 4:39 PM
    Monday, January 9, 2012 2:47 PM
  • In the Build tab of the properties of your project set the platform target to x86.
    Wednesday, January 16, 2013 6:31 PM
  • In the Build tab of the properties of your project set the platform target to x86.

    Hi Team, I wanted to send event confirmation to user in form of outllok appointmnt and my code is in ASP.Classic, windows server 2000 and no outlook installed.
    when i execute below code my webpage hangs up..
    Sub SendMeetingRequest()    
    Dim objOL   'As Outlook.Application    
    Dim objAppt 'As Outlook.AppointmentItem    
    Const olAppointmentItem = 1   
     Const olMeeting = 1          
    Set objOL = CreateObject("Outlook.Application")    
    Set objAppt = objOL.CreateItem(olAppointmentItem)   
    With objAppt  .Subject = "My Test Appointment"      
     .Start = Now + 1        
    .End = DateAdd("h", 1, .Start)                   ' make it a meeting request       
     .MeetingStatus = olMeeting       
     .RequiredAttendees = "someone@somewhere.dom"      
     .Send    
    End With     
        Set objAppt = Nothing   
    Set objOL = Nothing
    End Sub

    Is that because outllok not installed in my server? if yes then please let me know other solution

    Monday, October 27, 2014 9:33 AM