Using The Script "Automatically File Messages and Attachment

I attempted to use this script as is but without success.

According to the description here:
http://blog.devontechnologies.com/2012/06/tuesday-tip-even-better-mail-rule-script/
you only have to define rule with the name of Group to which you want to send the email. However, I’m wondering if you need to include the database name?

My apologies I’m not “Script Savvy”.
I looked inside the script and it refers to the database but I don’t understand where it would get the database name from.

Note, in my tests I have the database open and so that isn’t the problem. What appears to happen is that the email is delivered to the Global Inbox, as opposed to the Group Defined in the name of the Rule.

Ultimately what I’m trying to do is to write an “Act On” rule that will add “mail tags” to an email and then send it to a Group inside a particular database in DTPO. Depending on the email the database could any one of six.

Any suggestions as to the source of my problem would be appreciated.

Thanks

Be sure to store the script in ~/Library/Application Scripts/com.apple.mail

The script puts the messages located by the rule into a group in the Global Inbox which has the same name as the rule. If that group does not exist, the script will create it. So, if your Rule’s name is “Rule 9” then a group with that name in the Global Inbox will be created, or if that group exists already the rule will use the existing group.

Testing this over here, I found that I had to quit Apple Mail and relaunch it before the rule would work. I think this is an Apple Mail shortcoming, not a problem of the script.

If you want to use a database other than the Global Inbox, then open the script in AppleScript Editor and look for this line:


property pDatabasePath : ""

In the quotes (keeping the quotes) put the path of your database, for example:


property pDatabasePath : "~/Documents/My Databases/My Fermat Solution.dtBase2"

@korm

Thanks for your response - You half solved the problem.

Following your suggestion I solved the issue of getting to the database.

However, the script appears to be having trouble finding the correct Group.

Example
In the target database I have a group called “Interests”.
I set the “description” of the rule to “Interests”.
Note the rule is located in “Act On Rules” - I don’t know if this would effect the result. Intuitively I suspect not.

I execute the rule through the keystrokes Control N, and the feedback message says the script executes.
However, when I look at the result the script has created a Group called “Blog” and placed the email in that Group.

As a test I change the rule description to “Rule 9”. On this occasion I expect the script to create a Group called Rule 9 because no such rule exists in the database.
However, the result is the same as before the email is transferred to the Group “Blog”.

Any further suggestions would be appreciated.

Thanks

I can see that when the script is run from an Act-On rule, that Act-On is sending the script the name of the first rule in Inbox Rules. This is likely because the script was written to use input from Mail. There are ways to rewrite the script, or, better, to write a new script to work with Act-On. That would have to come from some other poster; I have no use for the rule, so I’m not interested in fixing it. Sorry.

Actually, IMO, the best best is to go over to the Indev forums and ask how to get the name of an Act-On rule into an ApplesScript rule handler.

Thanks for your help, very much appreciated.

I’ll follow up on your suggestion for the Indev forum.

I located a recent thread in Indev’s forum (mid-March 2013) that suggests it might not be possible to get the name of a MAO rule via ApplesScript. The thread is OT, but here – scroll down and read post #3 from “Bob”:

If this is the case, you’ll need to find a different approach, or not use the DEVONthink script in a MOA rule. Or, most simply, merely spoof the situation and create a dummy rule name at the top of the list of Mail’s Rules, which would be used by default as the name of the destination group for imports.

:smiley:
The main script “Automatic…” now works with “Act On” - http://www.indev.ca/MailActOn.html.

I spoke to the developers at indev and they’ve made some changes so that Act-On interacts with the script to deliver the email into a targeted group.

To set this up I duplicated the automatic script and changed the path to the target database. Then I made an “Act On” rule using the modified applescript. The description of the rule is given the name of target group. Thus if you wanted to deposit emails into top level group called Blog you just make the rule description “Blog”. If you wanted to target a child group such as website/blog then you make the description “website/blog”.

Sorry but I don’t know when this will be formally released, the developers were generous enough to let me test a beta version.

Thanks to Beth & Scott at indev their help and to korm taking the time to get me educated.

@dorich, that’s good news. I’ll be looking for the updated MAO from Indev in the weather report 8)