I have created windows service in .Net 4.0. Service is written to open outlook client, read emails from Inbox folder, downloads attachments.The code written is correct, since I have run & tested it in windows application project.
But when I install the web service using "installutil" and run it, the service throws following error on following line of code:
private static Microsoft.Office.Interop.Outlook.Application app = null;
private static Microsoft.Office.Interop.Outlook._NameSpace ns = null;
private static Microsoft.Office.Interop.Outlook.Attachments attachments = null;
Outlook.Application myApp = new Outlook.Application();
Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
ns = myApp.GetNamespace("MAPI");
Error:
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80010001 Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
FYI, the service is fails to run on my local machine.
I feel that service might require some permission, if so please let me know how to assign permissions to windows service.
Please Help.
What I have tried:
private static Microsoft.Office.Interop.Outlook.Application app = null;
private static Microsoft.Office.Interop.Outlook._NameSpace ns = null;
private static Microsoft.Office.Interop.Outlook.Attachments attachments = null;
Outlook.Application myApp = new Outlook.Application();
Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
ns = myApp.GetNamespace