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

  • Question

  • I have written an Office Tools application (not an Outlook Add-in, but rather a standalone tool) that uses the Word, Excel, and Outlook Interops.  The application builds and compiles with no errors.

    However, the last step is to create an email with this code:

    Sub SendDocumentAsAttachment(emailBodyText As String, Addressee As String)

            Dim oOutlookApp As Microsoft.Office.Interop.Outlook.Application
            Dim oItem As Microsoft.Office.Interop.Outlook.MailItem

            oOutlookApp = New Microsoft.Office.Interop.Outlook.Application()
            oItem = oOutlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

            With oItem
                .To = Addressee
                .Subject = "Committee Meeting Announcement"
                .Body = emailBodyText
            End With


            oItem = Nothing
            oOutlookApp = Nothing

        End Sub

    The subject error occurs at this step:

            oItem = oOutlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

    The error is:

    System.InvalidCastException: '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).'

    I have researched this error and am not sure why it occurs.  I have a brand new machine (there was never any other version Outlook installed) so I don't have a version error in the registry.  I have confirmed this by looking for anything other than version 9.6 in the registry for the {00063001-0000-0000-C000-000000000046} keys.  

    I have also confirmed that the MSOUTL.OLB is properly registered (it is).

    Any help would be greatly appreciated.  Also, I don't know why the the text size of this post is changing as I type it.  Weird.


    Tuesday, January 14, 2020 6:04 PM