I know this has been discussed earlier but I couldn\'t find a satisfactory answer.
I have an e-mail file (.msg) which I open like below and then call Display.
Doing things like this:
mail = (Microsoft.Office.Interop.Outlook.MailItem)oApp.Session.OpenSharedItem(fileName);
will cause the references to not be disposed of even when you call ReleaseComObject because the reference to the child object hasn't been disposed of properly.
You should make the calls like this:
session = oApp.Session;
mail = (Microsoft.Office.Interop.Outlook.MailItem)session.OpenSharedItem(fileName);
And you should dispose of each of these sub-objects, like session, in turn.
If you're using .NET's COM-interop features (you are) then you shouldn't need to worry about this.
COM tracks reference counts - and when the ref count reaches 0 COM objects get released automatically - and .NET takes care of working with the standard COM reference counting mechanism for you.
If you were P/Invoking into a C library things might be different - but you shouldn't have any worries in a standard scenario like yours.