Correct COM clean up??

G

Guest

Hi,

I've no COM experience, and I'm using the following snippet after adding
outlook com module to my references. The code below does the job, so I'm
happy... but also concerned that I'm not getting all cleaned up after the
objects goes out of scope. Do I need any Marchal.ReleaseComObject stuff here??

Outlook.ApplicationClass app = new Outlook.ApplicationClass();

Outlook.MailItemClass mi =
(Outlook.MailItemClass)app.CreateItem(Outlook.OlItemType.olMailItem);
mi.BodyFormat = Outlook.OlBodyFormat.olFormatPlain;
mi.Body = sb.ToString();
mi.Subject = "Project definition update";
mi.Display(new object());
 
V

Vadym Stetsyak

Every time a COM interface pointer enters the common language runtime, it is
wrapped in an runtime callable wrapper, which has the reference count. To
decrement it you have to call Marshal.ReleaseComObject Method ...
 

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