Created
September 7, 2023 04:34
-
-
Save SKaplanOfficial/c0a5ce0c43ebce021aaa20328d9fb84d to your computer and use it in GitHub Desktop.
Example JXA script to perform mail actions. Place the script in ~/Library/Application Scripts/com.apple.mail/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function performMailActionWithMessages(messages, options) { | |
// do stuff, e.g.: | |
const app = Application('System Events'); | |
app.includeStandardAdditions = true; | |
// messages are provided as a list | |
app.displayDialog(messages.map((message) => message.subject()).join(', ')) | |
// options are provided as an object with two properties: inMailboxes and forRule | |
// both options can be undefined | |
if (options.inMailboxes) app.displayDialog(options.inMailboxes.map((mailbox) => mailbox.name()).join(', ')) | |
if (options.forRule) app.displayDialog(options.forRule.name()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment