"Run Applescript" rules do not work after relaunching Mail.app
This is a reproducible problem.
Create an apple script named DebugDialog.scpt and attach it to a rule:
Here is the script:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
display dialog "In AppleScript"
end tell
end perform mail action with messages
end using terms from
If the script runs, a dialog box should pop up.
If you run the rule after immediately starting Mail.app, the script does not run. However, if you go into the rule preferences and select the DebugDialog.scpt script as the target of the "Run Applescript" action, it will start working. Now if you quit and restart mail it will stop working again.
This is a very annoying bug since my Mail Act-On rule works when I log into my account without going through the special preferences step.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Scott on 01 Dec, 2009 10:18 PM
Is it a case that the rule is not running or that the script is not running -- try adding a color message action to the rule and seeing if this works upon restarting Mail.
3 Posted by mlaster on 02 Dec, 2009 08:09 PM
The rule is being run. If I change the action to set the message color the rule fires. It seems to just be the Applescript rules that are failing.
4 Posted by Tom Fisher on 13 Jan, 2010 09:01 PM
I have the same issue. As you say, it is a quite annoying bug. It would be very nice if this bug was identified and fixed. Since it is reproducible, is there any reason it is not being looked in to for a fix?
Support Staff 5 Posted by petra on 01 Mar, 2010 07:15 PM
Sorry about the delay in response but we've working like mad on MailTags 2.5. We've created a ticket for this issue and have boosted the fix priority.
6 Posted by Gary Stripling on 18 Mar, 2010 08:28 PM
I emailed an AppleScripts developer about this problem and he wrote me this:
You should send the developer of MailTags an email, alerting him of the fact, that having MailTags installed will break AppleScript in Mail - the following simple script doesn't work with MT installed (after selecting one message in Mail before running the script) but works just fine without MT:
-- tell application "Mail" to get properties of (item 1 of (get selection))
Any news of a fix in the works?
7 Posted by Daniel on 18 Apr, 2010 08:58 AM
I'm experiencing the same problem. Even though I re-assign the AppleScript as mlaster suggests it still doesn't fire...
Support Staff 8 Posted by Scott on 19 Apr, 2010 02:38 PM
I did a quick fix to a minor applescript problem in the following build
http://www.indev.ca/Downloads/PreRelease/MailTagsSLCR7b9.dmg
Can you let me know if this fixes your issue?
9 Posted by mlaster on 19 Apr, 2010 02:54 PM
No, after installing it Mail Act-On still fails to run my AppleScript.
Support Staff 10 Posted by Scott on 19 Apr, 2010 03:39 PM
Thanks for the confirmation. I will keep this as an issue to be fixed then.
11 Posted by Pierce Wetter on 19 Apr, 2010 04:17 PM
You know, it seems to be path related. Because if I launch mail, then navigate through the rules and "touch" the applescript rule by selecting the EXACT SAME FILE. It works until I quit an re-launch mail.
So I would just point the debugger at where you're running the applescript, pick almost any applescript file, and see what things look like both before and after re-launching Mail.
That is:
I bet its a simple fix.
12 Posted by Daniel on 21 Apr, 2010 08:14 AM
Hi,
Tried to download the build but the dmg seems to be corrupt. Can you post a new one.
Thanks
Daniel
13 Posted by Jason Y. on 24 Apr, 2010 01:51 PM
With 10.6.3, I can confirm the following:
If I have Mail Act-On installed and I don't have Mail Tags installed, scripts will silently fail to run when I either make them Mail Act-On rules or via standard Inbox rules.
If I then install Mail Tags (SLCR6), everything is fine, scripts run as expected, etc. etc.
I have a license for Mail Tags, but I'd prefer for my setup not to be dependent on it, so it would be great to fix this bug. Thanks!
Jason
Support Staff 14 Posted by Scott on 26 Apr, 2010 03:23 PM
Hi Jason
Thanks for this detail. This then seems to be an issue with Act-On. Can you confirm that a rule will work fine with AS action when you have it as a regular inbox rule when you don't have Act-On installed.
Something to test if you have the time.
I am looking to see if it is an effect of MAO being present or MAO being involved in edit the rule (and somehow the saving the rule has prompted it to not run the rule.
Many thanks if you can test these steps out.
15 Posted by Jason Yanowitz on 26 Apr, 2010 03:38 PM
Hi Scott,
I'll try to get to this, I'm a little swamped at the moment.
I noticed this was happening after I got a new mac, synced all my prefs via MobileMe, not via editing in Mail.app (all the rules were initially created under 10.5 on a separate computer). I haven't been using MT, so I initially only installed MAO, saw these issues, tried editing the rules (to point them at new copies of the scripts) to no avail, eventually discovered installed MT solved the problems.
Before I go through all this effort -- are you unable to reproduce these problems?
thanks,
Jason
Support Staff 16 Posted by Scott on 26 Apr, 2010 04:29 PM
I can't reproduce the problem
Here are the results of my tests
(I have tried with two applescripts one that beeps 5 times and one that brings the finder to the front.)
Without Act-On, create a rule that will apply an AS action. Test it out by sending yourself a email that would trigger the rule.
Quit Mail and relaunch and test again.
Install MAO and relaunch and test again
remove MAO and relaunch and test again.
Install MAO, Edit the rule to make a nominal change to name of the rule and Test again
remove MAO and relaunch Mail and test again.
One thing to note though is that Applescript commands that require user interaction (eg display dialog) may fail as the applescripts a not necessarily running in the foreground.
This applescript
Will beep 5 times rather than displaying the dialog box
Something to do is to put in some try blocks on your applescripts and see what is happening.
for example
The script above gave me the following error when I replaced beep 5 with the logging statement.
10-04-26 12:27:35 PM MailRule[25530] Error Finder got an error: No user interaction allowed. occured
This may tell you the script is running but is aborting early.
17 Posted by pdxmph on 02 Sep, 2010 06:23 PM
I'm just here to report the same problem:
When I restart Mail, an archiving script I've got for MAO fails to run. I get the Growl feedback that the script is running, but nothing happens. I don't even have to touch the script or re-assign it to the MAO action ... I just have to open the Act-On Rules tab in preferences and close it again and the script begins to work as it's supposed to.
18 Posted by anthony on 25 Oct, 2010 07:00 PM
Hi everyone,
Sorry about the wait but I believe we have a fix for you.
Here's the build; you can install it by unarchiving it and copying the contents to your ~/Library/Mail/Bundles folder.
19 Posted by mlaster on 25 Oct, 2010 07:18 PM
Cool, that seems to have sorted it out!. What turned out to be the underlying cause?
Support Staff 20 Posted by petra on 25 Oct, 2010 07:23 PM
Hello,
The problem was that the applescript would call back to Mail for the list of rules but Mail was only returning a subset of the rules.
petra closed this discussion on 25 Oct, 2010 07:23 PM.
mlaster re-opened this discussion on 26 Oct, 2010 03:18 AM
21 Posted by mlaster on 26 Oct, 2010 03:18 AM
No content.
petra closed this discussion on 26 Oct, 2010 01:05 PM.
mlaster re-opened this discussion on 10 Nov, 2010 09:21 PM
22 Posted by mlaster on 10 Nov, 2010 09:23 PM
For some reason my email reply ended up as a "no content". What I intended to say is that MailActOn.mailbundle.zip attached above does indeed solve the problem, but this fix does not seem to be in the 2.1.9 release. When I upgrade to the 2.1.9 release the bug comes back. If I remove it and put the bundle from the zip back in, the bug is fixed again.
Did it not get picked up in 2.1.9?
Support Staff 23 Posted by Scott on 11 Nov, 2010 12:22 AM
This has been fixed internally but not released yet. -- We will have a release soon.
Scott closed this discussion on 13 Dec, 2010 09:57 PM.