A bug was introduced in the hotfix that upped the Outlook 2003 SP version to 11.8010.6568. If you cancel a Send using code you get a "false" Inspector.Close event. If you then close the Inspector in the UI or using code you get the "true" .Close event.
This doesn't happen in other versions of Outlook or other builds of Outlook 2003. There you do not get an Inspector.Close event unless the Inspector is really closing. However, the order in which Inspector.Close and Item.Close will fire does vary depending on whether the item was sent or just closed.
A workaround I use is to set a timer object in the Send event handler if I'm canceling the send. I set the timer for 500 ms which gives WordMail a chance to repaginate the email, which is does if running when an item is sent or closed. I also set a class level flag to indicate that a send was canceled.
When the timer fires I can then close the Inspector if I want or take any other action I want. In the meantime the original "false" Inspector.Close event will have fired. There I check the flag value and if True I just exit ..Close. If False I continue with my shutdown code.
The solution works with all the Outlook versions I've tested it on.
-- 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
"Sanjay" <spatel005[ at ]gmail.com> wrote in message news:1146847646.517844.289610[ at ]u72g2000cwu.googlegroups.com...
[Quoted Text] > Sorry.. I provided some incorrect information.. Let me try again.. > > the the above events wired up, If is set the bool cancel to true in > MailItem_Send, MailItem_Close is skipped and Inspector_Close is fired. > Where as when I close the message window, MailItem_Close gets fired and > then there is a popup box displayed asking if I want to save the > message before closing. > > Now my issues is that I display custom UI elements in the inspector > window and need to place the cleanup code somewhere. This cleanup code > would include unwiring of events. > > Can't use Inspector_Close because it gets called event if the bool > cancel is set to true in MailItem_Close > > Can't use MailItem_Close because it gets called before the popup is > displayed asking the user if they want to save the edits for later as > draft and if the user hits cancel, the inspector is still available. > > Hope this makes sense. > > Sanjay >
|