【问题标题】:Mail Rules using JavaScript for Automation instead of AppleScript使用 JavaScript 而非 AppleScript 实现自动化的邮件规则
【发布时间】:2015-07-26 10:36:42
【问题描述】:

我正在尝试使用用于自动化的 Javascript 而不是 AppleScript 来构建 Mail.app 规则(在 OS X Yosemite 上),但我坚持基础知识。

我在 AppleScript 中看到了这段代码:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        # actual code here
    end perform mail action with messages
end using terms from

但我不清楚这如何转化为 JavaScript。

我定义一个函数吗?设置回调?我不清楚。

我看到有 performMailActionWithMessages 函数,但我不知道如何让它工作。

非常感谢任何指导!

【问题讨论】:

    标签: javascript email applescript osx-yosemite


    【解决方案1】:

    我终于明白了:

    function performMailActionWithMessages(messages) {
      messages.forEach( function(message) {  // if you want to iterate
      })
    };
    

    【讨论】:

    • 很遗憾你只有三个赞成票。反正你得到了我的。你在哪里找到文档?多年来一直试图寻找好的来源。 (对于 Javascript 自动化来说)
    • 我从来没有发现什么很棒的东西,只是一直在尝试,直到我找到了一些有用的东西。从那以后我再也没有回去过。
    • 我正在尝试这段代码,但没有触发事件。它在 applescript 中运行良好,但不能在 javascript 中运行。打开一个后续问题,提供更多详细信息:stackoverflow.com/questions/49117223/…
    • 从 AppleScript 转换的一般规则是 concatenateAndTitleCase 单词。由于 AppleScript 中的动作是on perform mail action with messages theMessages for rule theRule,所以在 JS 中它变成了performMailActionWithMessages(theMessages, theRule)
    猜你喜欢
    • 2018-08-13
    • 1970-01-01
    • 1970-01-01
    • 2011-08-22
    • 1970-01-01
    • 1970-01-01
    • 2016-10-16
    • 2018-08-11
    • 1970-01-01
    相关资源
    最近更新 更多