Firing Order of Events

For item-level events, you can clearly predict the sequence in which events will fire. However, events at the application level are less predictable. You cannot guarantee that event firing will follow a specific sequence either because different events cause a unique firing sequence or because, in future versions of Outlook, the event sequence might change. Some insights into a typical firing sequence are offered here. If you want to investigate further, it is suggested that you write Debug. Print Object EventName statements for each event procedure supported by a given object variable declared using the WithEvents keyword. The following list shows just such a debug sequence when a user opens a mail message, enters recipients for the message, types a subject and message body, and then sends the message. Again, don't take this sequence as invariable; it simply gives you a reasonable expectation of the event sequence when you send a mail message.

1. Inspectors Newlnspector

2. Mailltem Open

3. Explorer Deactivate

4. Inspector Activate

5. Mailltem Read

6. Mailltem PropertyChange To

7. Mailltem PropertyChange CC

8. Mailltem PropertyChange BCC

9. Mailltem BeforeCheckNames

10. Mailltem PropertyChange To

11. Mailltem PropertyChange CC

12. Mailltem PropertyChange BCC

13. Mailltem PropertyChange Conversation Index

14. Mailltem PropertyChange ReceivedTime

15. Mailltem PropertyChange Subject

16. Application ItemSend

17. Mailltem Write

18. Mailltem Close

19. Inspector Deactivate

20. Explorer Activate

You can see from the above that PropertyChange events fire for To, CC recipient, and BCC recipient before and after the BeforeCheckNames events. In fact, the message that generated the sequence above had only a single To recipient. You'll also notice that item-level events in VBA behave similarly to item-level events in VBScript. Unfortunately, a PropertyChange event does not fire when a user enters text in the message body.

Was this article helpful?

0 0

Post a comment