Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rate Thread Display Modes
Old 01-26-2013, 09:56 AM   #1
wesleyh
Registered User
 
Join Date: Jan 2013
Posts: 1
Why doesn't this simple applescript work any more in ML mail.app (as a rule)

It works only when you right click on the mail message and choose "run rules", but not on incoming messages (without interaction).

The first dialog is shown both when incoming or running manually, but the second dialog (with the id) is only shown when running manually. Nothing is shown in console.log

Any ideas?

Code:
using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with theMessage in theMessages
                display dialog "inside"

                set theId to id of theMessage

                display dialog "the id is " & theId

            end repeat
        end tell
    end perform mail action with messages
end using terms from
wesleyh is offline   Reply With Quote
Old 01-26-2013, 08:15 PM   #2
ganbustein
MVP
 
Join Date: Apr 2008
Location: Berkeley CA USA
Posts: 1,009
That's a bug in Mail. Sometimes it doesn't assign an id to a message right away. Attempting to get the id throws an exception. Usually the id has been set on an incoming message before your rules run, but not always. Even if the id has been set, Mail may show only some of the headers. I've reported it to Apple, and encourage you to do likewise.

I had to modify the AppleScripts I run from rules so that they detect missing id and/or missing but important headers, and defer such messages until later. (I set their color to an otherwise unused color, and schedule a shell script to run 10 seconds later. That script runs the AppleScript again, which this time processes all messages with that color. It gives up on a message that still seems incomplete after four such cycles.)
ganbustein is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:09 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.