Unable to cast COM object of type Microsoft.Office.Interop.Outlook RRS feed

  • Question

  • I'm running into a problem with the below error.

    Message=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: Interface not registered (Exception from HRESULT: 0x80040155).

    Using both Outlook 2019 and Visual Studio 2019, I'm using the code below and not finding any errors within my code. (Correct me if I'm wrong). I thank you for your time and assistance. 

    Imports Outlook = Microsoft.Office.Interop.Outlook

    Dim application As New Outlook.Application
            Dim newMail As Outlook.MailItem = DirectCast(Application.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem) ' --> This is where I get the error
            With newMail
                .To = ""
                .Subject = "subject"
                .Body = "body"
            End With

    I've found a way around using UIautomation, but the code is long using that option, and prefer a more simplified approach. Your assistance is much appreciated. 

    Tuesday, November 12, 2019 3:31 PM

All replies

  • Hello,

    This is a widely spread issue when dealing with COM libraries. Here is what the Error: Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. forum thread states:

    Sounds like you have a problem with your typelib registration.  Presumably, the Com interop layer is hitting the registry to try to locate the typelib.  It would start by looking under HKCR\Interface\{00063001-0000-0000-C000-000000000046}\Typelib.  The default value should refer to the guid for the typelib that defines the interface in question: which should be located under the following key: HKCR\Typelib\{00062FFF-0000-0000-C000-000000000046}.  There should be a version subkey and then a 0 subkey, and a win32 subkey under that.  The default value of the win32 key should point to the typelib (which is msoutl.olb).


    I'd recommend you check your Office directory for msoutl.olb.  If it is there, try running 'regtlib msoutl.olb'.  You should have regtlib on your machine is part of your Visual Studio install, I believe.  Anyway, reregistering the typelib will rewrite all of the necessary keys to the registry.  You will need administrative privileges for this operation. 


    The other possibility is that msoutl.olb itself is corrupt, in which case reinstalling Outlook should fix the problem.

    Try to "repair" your Microsoft Office installation. Go to Programs and Features, select Modify and then Repair Online. 

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, November 12, 2019 6:00 PM
  • Hi!

    Thank you for your quick response. I did try the repair option however still failed. To better understand what you mean about the msoutl.olb,  I googled and then search within what I believe is my directory and I did not have this or did I have the google search of regtlib.exe. Your assistance is much appreciated.

    Tuesday, November 12, 2019 6:34 PM