Releasing COM Components

N

Nenad Dobrilovic

I have created programmatically a structure of root MAPIFolder, with
subfolders and MailItems.

Is it necessary to explicitly release all items (subfolders and mail items)
or I can release only the root MAPIFolder?
 
K

Ken Slovak - [MVP - Outlook]

Best practice is to always release everything.

Since you provide no information about your development language or platform
or even the Outlook versions you're targeting it's impossible to say more.
 
K

Ken Slovak - [MVP - Outlook]

In that case in addition to setting all COM objects to null in the
procedures where you declare them you should also use
Marshal.ReleaseComObject() on them if you no longer need the objects or any
other related objects.

For example, if you have a locally declared Inspector object don't use
Marshal.ReleaseComObject() on it if you still need other instances of that
object anywhere in your code. Otherwise you get an RCW error when you try to
refer to the Inspector in other parts of your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top