[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Application_Quit() not firing?

Posted on 2004-10-27
7
Medium Priority
?
742 Views
Last Modified: 2008-01-09
Hi I'm doing a bit of a tutorial - the super-easy guide to outlook object model - from MS
One of the "hands on" examples is supposed to fire off an email when the application_quit() event occurs.

The first time I tried to quit outlook I got an error stating that (ummm can't remember error and can't reproduce (sorry!)) but the debug button took me to the Set NewMail = ThisOutlookSession.CreateItem(olMailItem) line.

I changed nothing. Now I get no error but the sub is not run!
I've pasted the very simple sub below together with the _quit() call to the sub.
Outlook 2000 SR1 (Win2k) Exchange Client.
Thanks

Private Sub Application_Quit()
PollRestaurant
End Sub
-----
Sub PollRestaurant()
    Set NewMail = ThisOutlookSession.CreateItem(olMailItem)
    NewMail.Subject = "please open this email and make your lunch choice"
    NewMail.Body = "use the voting buttons to make your selection"
    NewMail.VotingOptions = "Subway; McDonalds; Kebab; KFC"
    Set receiverOfMyMail = NewMail.Recipients.Add("removed to fight spam")
    NewMail.Send
End Sub

the email address above is set to a valid account in real life.
the macro works fine if not invoked via the quit() event.
0
Comment
Question by:QPR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 29

Author Comment

by:QPR
ID: 12429261
have rediscovered the error dialogue when I quit Outlook:
"Internal application error"

Also forgot to mention that I click "enable" when I start Outlook and it warns me of resident macros
0
 
LVL 3

Expert Comment

by:brd24gor
ID: 12445446
What is your security setting set to in Outlook (Tools > Macros > Security)?  If it is set to High, you may want to try and bump it down to Medium or even Low if you have a virus scanner running.  Possibly this could be keeping Application_Quit() from running?
0
 
LVL 3

Expert Comment

by:brd24gor
ID: 12445535
I recreated your problem and the security setting does appear to be the problem.  If you have your security set to High, it won't run the macro and won't prompt you at all.  If you have it set to Medium, Outlook will tell you there are macros and ask whether you want to disable or enable them, and if you click Enable, your Application_Quit() will run just fine.  However, Outlook will prompt you EVERY time you open it.  The Low security setting works like Medium except that you aren't prompted to enable macros.  They are automatically enabled.

Hope this helps!
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 29

Author Comment

by:QPR
ID: 12458368
if I set secuirty to "low" then it will fire *sometimes*
If I click the 'x' at the top right to exit Outlook then nothing. If I choose file-exit & log off then it will.
However it causes an "internal application error" and spews on this line:
 Set NewMail = ThisOutlookSession.CreateItem(olMailItem)

is the ThisOutlookSession session invalid for the application_quit event?
Meaning am I trying to refer to a session that has been closed/destroyed?
0
 
LVL 3

Accepted Solution

by:
brd24gor earned 200 total points
ID: 12462857
http://support.microsoft.com/default.aspx?scid=kb;en-us;292796

If you have any global variables, they will not work in the Application_Quit() event as described above in the Microsoft KB article.  You may be trying to refer to a variable that has been destroyed.  If you have any global variables, try declaring them locally in the Application_Quit() event.  The article also suggests making a COM add-in, which I don't have much experience in.
0
 
LVL 29

Author Comment

by:QPR
ID: 12466428
thanks.
With this in mind I put the whole of the code in the quit() event rather than calling it.

Private Sub Application_Quit()
Set NewMail = ThisOutlookSession.CreateItem(olMailItem)
    NewMail.Subject = "please open this email and make your lunch choice"
    NewMail.Body = "use the voting buttons to make your selection"
    NewMail.VotingOptions = "Subway; McDonalds; Kebab; KFC"
    Set receiverOfMyMail = NewMail.Recipients.Add("me@home.com")
    NewMail.Send
End Sub

other than the reference to ThisOutlookSession everything is pretty much self contained yet the same error occurs "internal application error"
Outlook 2000
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question