![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Is MailItem.Close() a synchronous or asynchronous operation? In other words,
if I first close my MailItem and then call Delete() on it, should this work? Bina |
#2
|
|||
|
|||
![]()
Calling Close on your MailItem closes the item, but does not destroy your
reference to it. You can therefore call Delete thereafter. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. "Bina" wrote: Is MailItem.Close() a synchronous or asynchronous operation? In other words, if I first close my MailItem and then call Delete() on it, should this work? Bina |
#3
|
|||
|
|||
![]()
I am concerned about whether the call to Close() is a synchronous or
asynchronous operation. If I am displaying an email, and I call the Close() function, and it is asynchronous, I may be trying to Delete the item while it is still being displayed. The background for my question is that I have created a temporary folder with an email in order to display it. I want to Close() the email and delete the folder and the email. However, sometimes (not in all cases) the delete operation fails with a permissions error. If I wait a while and then delete, or step through this process in a debugger, it never fails. So, I was wondering if Close() is actually an asynchronous operation. If so, is there a way to know when it has completed? "Alan Moseley" wrote: Calling Close on your MailItem closes the item, but does not destroy your reference to it. You can therefore call Delete thereafter. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. "Bina" wrote: Is MailItem.Close() a synchronous or asynchronous operation? In other words, if I first close my MailItem and then call Delete() on it, should this work? Bina |
#4
|
|||
|
|||
![]()
I do not know for certain if it is synchronous or not, but I suspect that it
is. Can you post the relevant section of your code. I suspect that you are under certain circumstances not setting the mailitem's object variable back to nothing before deleting the folder. Also, calling the mailitem's delete method invokes the inspector to close anyway, so you probably do not need to call it separately. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. "Bina" wrote: I am concerned about whether the call to Close() is a synchronous or asynchronous operation. If I am displaying an email, and I call the Close() function, and it is asynchronous, I may be trying to Delete the item while it is still being displayed. The background for my question is that I have created a temporary folder with an email in order to display it. I want to Close() the email and delete the folder and the email. However, sometimes (not in all cases) the delete operation fails with a permissions error. If I wait a while and then delete, or step through this process in a debugger, it never fails. So, I was wondering if Close() is actually an asynchronous operation. If so, is there a way to know when it has completed? "Alan Moseley" wrote: Calling Close on your MailItem closes the item, but does not destroy your reference to it. You can therefore call Delete thereafter. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. "Bina" wrote: Is MailItem.Close() a synchronous or asynchronous operation? In other words, if I first close my MailItem and then call Delete() on it, should this work? Bina |
#5
|
|||
|
|||
![]()
Close is synchronous but you can't delete the item in that event handler
without errors in some versions of Outlook. Outlook also caches items so you have to wait for it to be released. I usually use a timer to do the deletions and set up an array of EntryID's of items to delete. When the timer fires I sweep the array clean. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Alan Moseley" wrote in message ... I do not know for certain if it is synchronous or not, but I suspect that it is. Can you post the relevant section of your code. I suspect that you are under certain circumstances not setting the mailitem's object variable back to nothing before deleting the folder. Also, calling the mailitem's delete method invokes the inspector to close anyway, so you probably do not need to call it separately. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. |
#6
|
|||
|
|||
![]()
Hello,
What we have done at work is to create a thread In the Inspector Clos event : If RemoveItemAfterClose Then Dim TS As New System.Threading.ThreadStart(AddressOf WrapperMailItem.Delete) Dim t As System.Threading.Thread = New System.Threading.Thread(TS) Try t.Start() Catch ex As Exception MsgBox(ex.ToString) End Try End If Works like a charm "Ken Slovak - [MVP - Outlook]" wrote: Close is synchronous but you can't delete the item in that event handler without errors in some versions of Outlook. Outlook also caches items so you have to wait for it to be released. I usually use a timer to do the deletions and set up an array of EntryID's of items to delete. When the timer fires I sweep the array clean. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Alan Moseley" wrote in message ... I do not know for certain if it is synchronous or not, but I suspect that it is. Can you post the relevant section of your code. I suspect that you are under certain circumstances not setting the mailitem's object variable back to nothing before deleting the folder. Also, calling the mailitem's delete method invokes the inspector to close anyway, so you probably do not need to call it separately. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Close a Excel Workbook when close a userform in Outlook | [email protected] | Outlook and VBA | 2 | May 8th 08 02:54 PM |
MailItem Close Event | Robert Morley | Outlook and VBA | 8 | April 19th 07 09:03 PM |
Close Message, Close Outlook | cdf | Outlook - General Queries | 2 | April 16th 07 03:42 PM |
How to Add a MailItem to a Folder | Ron | Outlook and VBA | 2 | January 10th 07 08:53 PM |
How can I create a MailItem that displays like a received MailItem ? | Clive | Outlook - Using Forms | 0 | February 27th 06 04:14 PM |