Check out Build an Automator Quick Action To Snooze Email at YouTube for closed captioning and more options.
function run(input, parameters) { // set up applications var Mail = Application("Mail"); Mail.includeStandardAdditions = true; var Reminders = Application("Reminders"); var SystemEvents = Application('System Events'); // get the selected messages var messages = Mail.selection(); // loop through all messages for(var i=0;i<messages.length;i++) { // get the subject, sender and message id var subject = messages[i].subject(); var sender = messages[i].sender(); var id = messages[i].messageId(); // prompt for subject modifications and the snooze time var dialogResult = Mail.displayDialog('Email Snooze Reminder Title', { defaultAnswer: subject + ' from ' + sender, buttons: ['4 PM Today', '4 Hours From Now', 'Cancel'], defaultButton: '4 PM Today', cancelButton: 'Cancel', withTitle: 'Mail Snooze' }); // calculate the due date time var due = new Date(); if (dialogResult.buttonReturned == '4 PM Today') { due.setHours(16); due.setMinutes(0); due.setSeconds(0); } else if (dialogResult.buttonReturned == '4 Hours From Now') { due.setHours(due.getHours() + 4); } else { return; // cancelled, so quit } // get the new title reminderTitle = dialogResult.textReturned; // create a new reminder and add it var newReminder = Reminders.Reminder({ name: reminderTitle, body: "message://<"+id+">", dueDate: due}); Reminders.lists.byName("Email Snooze").reminders.push(newReminder); } // send a Control+Command+a to archive the selected messages SystemEvents.keystroke('a', { using: ['control down', 'command down'] }); }
Your excellent “Snooze Email” program is a real help, even for this 85 year old. Thank you for making the instructions so clear and understandable. The service you offer is a real blessing. Brad
I tried this but got an error: “Can’t get object”, when running the Javascript. I wonder what went wrong.
I figured this out. The script assumes that a Reminder list “Email Snooze” already exists. I needed to create this list first for it to work.
Wei: Yes, I say that at 5:52.
Hi, what a helpful thing I was looking for a long time! Thanks a lot and greetings from Germany!
Just one thing: I tried to set the reminder at 9pm in the script, which doesn’t work. It still shows me 4pm. How to change this?
Jörg: Look at the script carefully. You have to change those things in several places.
This looks like a great convenience. Assuming I install the script on both computers, will I encounter any issues if I access my three email accounts from two computers, a laptop and an iMac?
Lawrence: It should act just like if you did these steps manually on one computer. Try it and see.
This looks like a great convenience. Assuming I install the script on both computers, will I encounter any issues if I access my three email accounts from two computers, a laptop and an iMac?
Thanks Gary.
Oops, I hit the wrong button.
This is fantastic. I would however, like to set reminder to 9am the following day (as one of the options). I can see how to edit the time but not the date. Any ideas anyone?
Jonathan: Try to add + 1 to the line:
var due = new Date()
That’s excellent thank you. I tried other things, but not that!
Found it. I had to change “due.setHours(16) to (21). Thanks!
This is awesome!! How do I fix: The action “Run JavaScript” encountered an error: “Error: Error: Automator Workflow Runner (WorkflowServiceRunner, Email Action Required) is not allowed to send keystrokes.”?
Dean: Did you allow permissions like I show in the video?