User-2136619341 posted
Hi
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?
Thanks
Ashok