Kenneth Wilson
Member
- Outlook version
- Outlook 2016 32 bit
- Email Account
- Exchange Server
I'm trying to get Outlook to do some things when the user closes the application.
I tried using the app.quit event, but that's too late, because by the time it fires, Outlook has already released all of my variables/objects. I need to run my code in an event that fires before that.
I found some (sparse) documentation suggesting to use Explorer.Close() event for that reason. But I don't think the event is firing... or I've set it up wrong?
I declared global variables:
Private WithEvents MyExplorers as Outlook.Explorers
Private WithEvents MyExplorer as Outlook.Explorer.
In Application_Startup, I do:
Set MyExplorers = Application.Explorers
Set MyExplorer = MyExplorers.Item(1)
(And I've verified that it does get set)
Then I created:
Private Sub MyExplorer_Close()
>> This sub never runs. Why not?
(Further: I also created MyExplorers_NewExplorer() to verify that this event was firing. It does.)
I can find very little documentation or examples for the Explorer events.
Any help?
By the way -- the thing I'm ultimately trying to accomplish... While Outlook is running, I have a draft email that I use to log various stuff that I want logged. Before Outlook shuts down, I want it to Send that draft email to me. So have a global MyLog as MailItem, and I need to call MyLog.Send. That's what I want to put in MyExplorer.Close().
I tried using the app.quit event, but that's too late, because by the time it fires, Outlook has already released all of my variables/objects. I need to run my code in an event that fires before that.
I found some (sparse) documentation suggesting to use Explorer.Close() event for that reason. But I don't think the event is firing... or I've set it up wrong?
I declared global variables:
Private WithEvents MyExplorers as Outlook.Explorers
Private WithEvents MyExplorer as Outlook.Explorer.
In Application_Startup, I do:
Set MyExplorers = Application.Explorers
Set MyExplorer = MyExplorers.Item(1)
(And I've verified that it does get set)
Then I created:
Private Sub MyExplorer_Close()
>> This sub never runs. Why not?
(Further: I also created MyExplorers_NewExplorer() to verify that this event was firing. It does.)
I can find very little documentation or examples for the Explorer events.
Any help?
By the way -- the thing I'm ultimately trying to accomplish... While Outlook is running, I have a draft email that I use to log various stuff that I want logged. Before Outlook shuts down, I want it to Send that draft email to me. So have a global MyLog as MailItem, and I need to call MyLog.Send. That's what I want to put in MyExplorer.Close().