what is this error? "Retrieving the COM class factory for component with CLSID.." RRS feed

  • Question

  • User1228437946 posted


    I am writing some code to create an outlook mail item. My machine is X64 and does not have office product installed. I added "Microsoft.Office.Interop.Outlook" dll from .NET reference tab in VS2008.

                    Outlook.Application outlookObj = new Outlook.Application();  // <-- Error thrown from here                              
                    Outlook.MailItem mail = (Outlook.MailItem)outlookObj.CreateItem(Outlook.OlItemType.olMailItem);                
                    mail.To = "..";
                    mail.Subject = "..";
                    mail.HTMLBody = "";
                    string id = Guid.NewGuid().ToString();
                    mail.SaveAs(@"C:\" + id + ".msg", Outlook.OlSaveAsType.olMSG);

    When I run my code, I am gettign an error.. "Retrieving the COM class factory for component with CLSID {..} failed due to the following error: 80040154."

    I've tried changing the Debug mode to x86 according to another post here, but didn't work. This could be a naive question, but why is it COM class when the reference is added from .NET tab? And, how can I address this issue??


    Friday, July 30, 2010 6:40 PM


  • User-2005691517 posted

    You won't be able to create an Outlook mail object if Outlook is not installed on the machine. The interop is not enough.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 30, 2010 8:55 PM