0

Okay so I want to create a apple script that creates a new rule in the mac mail app where if I write a new email and the content of the mail is "Start applescript", I want a apple script to start.

Here is the code I have so far:

tell application "Mail"
set newRule to make new rule at end of rules with properties {name:"Apple script rule", forward message:""}
tell newRule
    make new rule condition at end of rule conditions with properties {rule type:message content, qualifier:does contain value, expression:"Start applescript"}
end tell

end tell

4

2 回答 2

0

我不确定你想要真正实现什么。

转发消息:属性不能为空,即“”

你必须有一些东西,否则脚本将失败。

于 2013-05-20T21:27:18.857 回答
0

这将起作用;然而,虽然该规则运行良好,但每次连续运行它时效果都不是很好,并且似乎试图将这些东西添加到它创建的第一个规则中。它确实创建了一个规则,所以就是这样。

将路径(第二行的最后一件事)更改为您尝试运行的脚本的路径。

tell application "Mail"
    set newRule to make new rule at end of rules with properties {name:"Woohoo rule", forward message:"data@data.gov", run script:(POSIX file "/Users/Paul/Library/Application Scripts/com.apple.mail/spam")}

    tell newRule
        make new rule condition at end of rule conditions with properties {rule type:message content, qualifier:does contain value, expression:"run applescript"}
    end tell

end tell
于 2015-12-06T18:31:52.287 回答