reading outlook email from asp.net application

Nov 14 2018 3:19 AM
Hi all
We have one asp.net application with in this application we read outlook emails using OutLook = Microsoft.Office.Interop.Outlook; dll
It is working in local fine but when we host on IIS server then we got a problem and i am getting following error.

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

 
how to solve this error please help me
my code id here
OutLook._Application _app = new OutLook.Application();
OutLook._NameSpace _ns = _app.GetNamespace("MAPI");
OutLook.MAPIFolder inbox = _ns.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox);
_ns.SendAndReceive(true);
 
 
for (counter = inbox.Items.Count; counter >= 1; counter--)
{
dt.Rows.Add(new object[] { counter,linforcontact, item.SenderName, item.SenderEmailAddress, Subject, item.SentOn.ToLongDateString() + " " + item.SentOn.ToLongTimeString(), Reply, ReplyAll, Forward});
}
Please help me to fixed this 

Answers (4)