Thread: Delete MailItem
View Single Post
  #2  
Old January 23rd 07, 06:38 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Delete MailItem

You should always release objects when done with them. I'd put the nulling
of the object before calling to release the COM object though. I don't see
any need for DoEvents given the code you showed.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"j" wrote in message
oups.com...
Hi,

While i delete MailItem ( myMailItem.Delete() ) should i also call
ReleaseComObject,
and is it good idea to call Application.DoEvents after deleting item??

please review the code snippets:

...............
..........
............
mailItem.Delete();
Application.DoEvents();

Marshal.ReleaseComObject(mailItem);
mailItem = null;

.....................
.............................


is it right way ???

TNX in advance;


Ads