I'm trying to quit outlook.application after I'm done with the object like the following
//variables intialisation
var outlookApp = new Microsoft.Office.Interop.Outlook.Application();
RDOFolder store;
RDOStore mailbox;
RDOSession session;
session = Redemption.RedemptionLoader.new_RDOSession();
session.MAPIOBJECT = outlookApp.Session.MAPIOBJECT;
mailbox = session.GetDefaultFolder(rdoDefaultFolder.olFolderInbox).Store;
store = session.GetDefaultFolder(rdoDefaultFolder.olFolderInbox).Parent;
//...code goes on
//Quitting
session.LogOff();
outlookApp.Quit();
Marshal.ReleaseComObject(store);
Marshal.ReleaseComObject(mailbox);
Marshal.ReleaseComObject(session);
Marshal.ReleaseComObject(outlookApp);
What could be the problem? I trying to wait for a couple minutes to make sure they were nothing going on in the outlook process bloking it to quit but it never close itself. When I click on the outlook icon to close it manually I get the following error:
Outlook cannot display this view
But If I break before session.LogOff(), open outlook in full mode and restart the code then it will close without problem.
Thanks!