Outlook Interop Element not found

Pauly C 1 Reputation point
2021-02-19T19:22:09.437+00:00

We have an application that has been running for several years with no issues. About a month ago we started getting errors when using any Office.Interop object. Word, Excel, and Outlook (Office 365)...

We have read every posting about office installations, registry entries and so forth. None of them have helped. We have about 1200 users in 5 different countries and having them all constantly doing office repair is not practical, nor does it seem to be working. The Outlook add-ins that we have operating all seem to be working fine. We have brought this up to the global IT group, which is in Europe, and they don't seem to feel it is something that they are doing with the updates. Since the error is generating our of our software, the problem is on us.

To make it more aggravating, not all the machines have this problem at the same time. Out of say 20 machines in an office, 5 may have this issue for two days, then start working again. Two days later four different machine have this problem and the rest are working fine.

So, the question is, is there a work around to prevent the Interop from being subject to this sort of bug, and if not, are there any other viable solutions for taking word documents, filling them in and then mailing them out as PDF's? Has anyone else had this on an enterprise level? Seems that all of the postings about this deal with single machines and local fixes.

This is the code that generates the error, and the error below.

    private void button1_Click(object sender, EventArgs e)
    {

        Outlook.Application outlookApp;
        Outlook._MailItem oMailItem;

        outlookApp = new Outlook.Application();

        // Error generates here.
        oMailItem = outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
    }

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: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)).'

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,720 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Cheong00 3,476 Reputation points
    2021-03-04T08:16:59.003+00:00

    Actually for this TYPE_E_ELEMENTNOTFOUND error, if your development machine also have Office 365 Outlook, try remove reference to Outlook Interop in your project, add it again and recompile. Sometimes this is enough to make it work.

    Chances are the object type you're using has less members than the time when your Interop assembly is created, hence the problem.

    0 comments No comments