Mail Rules using JavaScript for Automation instead of AppleScript

妖精的绣舞 提交于 2019-12-22 05:27:17

问题


I'm trying to build a Mail.app rule (on OS X Yosemite) using Javascript for Automation instead of AppleScript, but I'm stuck on the basics.

I see this code in 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

but I'm unclear how this translates to JavaScript.

Do I define a function? Set a callback? I'm unclear.

I see that there is the performMailActionWithMessages function, but I can't figure out how to get it working.

Any guidance is very much appreciated!


回答1:


I finally figured it out:

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


来源:https://stackoverflow.com/questions/30243646/mail-rules-using-javascript-for-automation-instead-of-applescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!