title: Applescript to run at shut down
body: <p>I am trying to make an application using AppleScript which can remind to check my mails, if I forget to check, at shutdown.</p>
  
  <p>I took help from this link: <a href="http://discussions.apple.com/thread.jspa?threadID=1375949&amp;tstart=0&amp;messageID=7088687#7088687" rel="nofollow noreferrer">http://discussions.apple.com/thread.jspa?threadID=1375949&amp;tstart=0&amp;messageID=7088687#7088687</a></p>
  
  <p>In this link they have suggested that I can run a quite application which can be started at login and when I will try to shut down, system will try to close it and desired result will be obtained! </p>
  
  <p>I have tried this script code:</p>
  
  <pre><code>say "Good morning Miraaj! I will be reminding you to check your mails at shutdown. Have a rocking day!!"
  </code></pre>
  
  <p>on quit</p>
  
  <pre><code>set the alert_message to "Have you checked your mails?"
  display dialog the alert_message buttons {"Yes", "No"} default button 1
  set the my_choice to the button returned of the result
  if my_choice is "Yes" then
      tell application "Finder"
          shut down
      end tell
  else
      tell application "Safari"
          open location "www.gmail.com"
      end tell
  end if
  continue quit
  </code></pre>
  
  <p>end quit</p>
  
  <p>but it is not working for me!</p>
  
  <p>Can anyone suggest where I may be wrong ??</p>
  
  <p>thanks, </p>
  
  <p>Miraaj</p>