3 Replies Latest reply: Nov 3, 2008 11:22 AM by Bill Rising
Bill Rising Level 2 Level 2 (240 points)
When I try to create a new mail message in Mail.app via AppleScript, the AppleEvent handler barfs. Here is a snippet which should work. It is taken from a script which once worked well, but now does not function. (I have no idea when the script stopped functioning, because I have had no need of it until today.)

*tell application "Mail"*
*make new outgoing message with properties {visible:true, subject:"test", content:"this is failing"}*
*end tell*

Does anyone have a clue why this is failing? The specific message is "Mail got an error: AppleEvent handler failed." I'm using Mail 3.5 under Mac OS X 10.5.5.


PowerBook G4, Mac OS X (10.5.5)
  • Joel D. Reid Level 3 Level 3 (815 points)
    How many technicians does it take to change a light bulb?
    "None, we have that same bulb here in our lab and it works fine."

    Joking aside, sorry... tried your snippet and it works as would be expected. Time to start narrowing the source of the problem down; try it in another OS X account on the same computer, repair permissions, look at your logs, run all relevant software updates, temporarily move your ~/Library/Mail folder to eliminate it as a factor, etc.
    Let us know what happens, especially if you get it working again. Best,
  • Bill Rising Level 2 Level 2 (240 points)
    I did get it working while trying to find the culprit. I have both MailTags and Mail Act-On from http://indev.com installed.

    1. I tried the script on another, similarly set up machine---it failed.
    2. I quit Mail.app.
    3. I moved my MailTags Preferences, together with ~/Library/MailTags.mailbundle and ~/Library/MailTags Extras to a folder on the desktop.
    4. I restarted Mail.app.
    5. The script worked.
    6. I quit Mail.app.
    7. I put my MailTags Preferences and ~/Library/MailTags.mailbundle back where they belonged.
    8. The script worked.
    9. I quit Mail.app.
    10. I put ~/Library/MailTags Extras back where it belonged.
    11. The script worked. MailTags' behavior was also unchanged.

    So... in the end, I now have just what I had before, but the script works fine. There must've been some sort of cruft in some cache which got cleared out when MailTags was not loaded once.
  • Bill Rising Level 2 Level 2 (240 points)
    An even simpler solution:

    1. Turn off the MailTags Debug menu.
    2. Restart mail