Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mail Rules using JavaScript for Automation instead of AppleScript

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!

like image 563
Daniel Morrison Avatar asked May 14 '15 17:05

Daniel Morrison


1 Answers

I finally figured it out:

function performMailActionWithMessages(messages) {
  messages.forEach( function(message) {  // if you want to iterate
  })
};
like image 70
Daniel Morrison Avatar answered Nov 15 '22 00:11

Daniel Morrison