A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook Add-in + Sequence of Events..



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 5th 06, 06:10 PM posted to microsoft.public.outlook.program_addins
Sanjay
external usenet poster
 
Posts: 21
Default 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.

Ads
  #2  
Old May 5th 06, 06:47 PM posted to microsoft.public.outlook.program_addins
Sanjay
external usenet poster
 
Posts: 21
Default 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

  #3  
Old May 6th 06, 07:26 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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


  #4  
Old May 8th 06, 06:05 AM posted to microsoft.public.outlook.program_addins
Rog
external usenet poster
 
Posts: 62
Default 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

  #5  
Old May 9th 06, 10:20 PM posted to microsoft.public.outlook.program_addins
Sanjay
external usenet poster
 
Posts: 21
Default 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?

  #6  
Old May 9th 06, 10:34 PM posted to microsoft.public.outlook.program_addins
Sanjay
external usenet poster
 
Posts: 21
Default Outlook Add-in + Sequence of Events..

One more thing.. you have to use the word mail editor to get the above
described behavior...

  #7  
Old May 10th 06, 06:19 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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...


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add holiday events beyond Dec. 31, 2005? Doug Slattery Outlook - Calandaring 2 April 14th 06 02:25 AM
fail to deliver a group mail --- "503 BAD SEQUENCE OF COMMANDS" SpringFlower Outlook - General Queries 1 April 6th 06 04:45 AM
unable to add events to my calendar. Lee Richardson Outlook - Calandaring 1 March 8th 06 08:09 PM
Can I add colour to events in outlook calender 2000? Sue Mosher [MVP-Outlook] Outlook - Calandaring 0 January 18th 06 11:19 PM
Collating sequence seems strange Jim K Outlook - Using Contacts 2 January 17th 06 09:44 PM


All times are GMT +1. The time now is 03:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.