Web service - Retrieving the COM class factory for component with CLSID error RRS feed

  • Question

  • User-2136619341 posted


      I have written a web service that reads emails from Outlook configured on the same server.Web service works fine when i debug it in  Visual studio development environment. It reads emails from Outlook.

    But when i select  -- > Use IIS Web server in web service project properties and run , it shows the following error.

    + e {"Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005."} System.SystemException {System.UnauthorizedAccessException}

    I have written the code as follows to read emails in the Web method.

                    Microsoft.Office.Interop.Outlook.ApplicationClass oOutlook = new Microsoft.Office.Interop.Outlook.ApplicationClass();
                    Microsoft.Office.Interop.Outlook.NameSpace oNS = oOutlook.GetNamespace("MAPI");
                    Microsoft.Office.Interop.Outlook.Recipient oRep = null;
                    Microsoft.Office.Interop.Outlook.MAPIFolder oFolder = null;

                    oNS.Logon("profile", "pwd", false, false);
                     oFolder = oNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);


    How to avoid this error and enable the  Web service  on the IIS server to read outlook mails?







    Thursday, June 18, 2009 9:12 AM

All replies

  • User334174592 posted

    When you are debugging, you are usually using the internal web server ('Cassini") that comes with Visual Studio. It is running with your permission. When you run the website using IIS, it is running using the account configured in IIS. This account is the one that does not have permission. This account is usually the "NETWORK SERVICE" account.

    Thursday, June 18, 2009 9:33 AM