PDA

View Full Version : Using WithEvents



Rjbudz
11-20-2017, 12:02 PM
Hi all. Here’s the situation:

I’m using Outlook 2016 and am trying to allow users to edit any email they open.

To do this, I need to use WithEvents to trap the open email event. This requires creating a Class module, as a regular module won’t allow this. However, a class must be instantiated. To do this I need to run some code. To get this code to run, it’ll have to be triggered when an event occurs.
But I cannot trap events unless I am able to instantiate Withevents. Which I cannot do unless I can run code to do so. Which I cannot do unless I can trap an event …

All code I’ve found relating to this simple puts the Withevents declaration at the top of the module. That obviously won’t work.

(Macros are enabled; in the regular module in the let dropdown the only option is “General”, no “Application events” choice)

It seems to be one of those “It’s so obvious” things, like how to use a keyboard. But to me it isn’t.
What am I missing? Thanks.

skatonni
11-21-2017, 03:26 PM
Application events are in ThisOutlookSession.