![]() |
Outlook Add-in + Sequence of Events..
I an trying to get a sense of the sequence of events that are fired
while creating and sending a new mail item. I am using Outlook 2003 SP2 + VSTO. I have an Add-In that has the following events wired up. Inspector_NewInspector MailItem_Open MailItem_Send MailItem_Close Inspector_CloseInspector Here is the scenerio that confuses me. When I create a new mail, add the recipients, subject, message body and then close the inspector. Outlook fires the MailItem_Close and then asks if the user would like to save the changes. Now if you hit cancel here, the inspector remains open but the inspector_Close event gets triggered. I have to place the cleanup code somewhere and now I'm not sure where the correct location would be. Any help will be appreciated. Thanks. |
Outlook Add-in + Sequence of Events..
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 |
Outlook Add-in + Sequence of Events..
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" wrote in message oups.com... 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 |
Outlook Add-in + Sequence of Events..
I would recommend an inspector wrapper. this example is for explorers,
but the concept is the same: http://www.outlookcode.com/codedetail.aspx?id=789 let me know if you have any troubles. Rog Sanjay wrote: 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 |
Outlook Add-in + Sequence of Events..
Ken --
Thanks for the quick reply.. I was getting a little frustrated.. I ended up storing the cancel value in the wrapper for mail item and then check that value in inspector close before doing the cleanup. Seems to be working now. But discovered something else... When opening email messages from outbox, the first time MailItem_Open event is fired, but close it and try opening it again and it will not fire the MailItem_Open... Is this a bug too? |
Outlook Add-in + Sequence of Events..
One more thing.. you have to use the word mail editor to get the above
described behavior... |
Outlook Add-in + Sequence of Events..
It sounds like the item isn't being closed if you don't get another Open
event. I haven't seen that here in either the Outlook or Word editors. -- 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" wrote in message ups.com... One more thing.. you have to use the word mail editor to get the above described behavior... |
All times are GMT +1. The time now is 11:33 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com