Hi, this is Gary with MacMost.com. Today let me show you how to make an automator QuickAction
that will allow you to snooze email.
MacMost is brought to you thanks to a great group of more than 800 supporters.
Go to MacMost.com/patreon. There you can read more about the Patreon Campaign.
Join us and get exclusive content and course discounts.
So I often get asked about this and this is actually a functionality that I wanted as well.
I want to be able to snooze an email message. So an email comes into my Inbox.
I want to do something with it but not right now. Maybe at the end of the day. Maybe tomorrow.
Maybe in a few hours. It would be great if there was a way that I could get it out of my Inbox
but still have a reminder to go and do something with that email message later on. Now you could
do this manually. Here I've got the Reminders app open. I can drag and drop an email from my inbox
into the Reminders app. You could see here there's actually a link to that email message.
I can actually double click it and it opens up that email message in Mail. It evens works if
I were to Archive the email and then go to Reminders, double click on the icon there,
and now I can open up that email even though it's in my Archive. Then I can go to this
Reminder here. Set a Remind me on Day and set a Time and have it remind me about that email.
That's a lot of steps every time you need to do that. So the idea here is to Automator and
see if we can do it in one or two quick steps. So I'm going to launch Automator
and I'm going to want to create a QuickAction. A QuickAction will allow us to assign a keyboard
shortcut to it. Then this workflow is going to receive No Input in just the Mail app.
That's the only place we're going to use it. The only action in the workflow is going to
be a bit of JavaScript. So I'm going to drag over the default run JavaScript action here
and this is where our script will go. This is going to be a really long tutorial if I were
to build it step-by-step. So I'm going Paste in my results here and then walk you through it.
So this is enclosed in the standard default function you get when you add the Run JavaScript
action. Now first I need to define three things that I'm going to be accessing during this script.
The first one is the Mail app. So that's simply Mail equals Application Mail. I'm going to use
include standard additions so I can control Mail with scripting. Then I need to do the same thing
for the Reminders app since I'm going to be saving a new reminder. I'm also going to get SystemEvents
which will allow me to issue keyboard commands. I'm going to use that in the very last step here.
Now the idea here is to select messages in Mail and then use this keyboard shortcut. So I'm going
to get the messages that are selected, usually it will just be one message but this will actually
work if you've selected multiple messages. Next I'm going to loop through each of the messages in
this list. Now this does two things for us. First if you have more than one message selected
it will do it for each message. But also if you have no messages selected
nothing will happen. We don't have to check to see if a message is selected because this loop
will simply not go through even once if there are no messages in this list. Then I'm going to get
three bits of information about the message. The Subject, the Sender, and the Message ID.
Now that's all I really need to create the reminder. I want to put the subject and the sender
in the text of the reminder and the message ID I'm going to use to link to the message.
However, the piece of information I don't have is how long until I get a reminder. Now I could
just hard code a set amount of time like 4 hours or 24 hours into this. But instead I'm actually
going to ask for a time. I'm going to give two options and also a cancel button that will simply
just cancel this whole operation. So I'm going to use Display dialogue. But I'm going to do
even more than just ask for the time. I'm actually going to show the Subject and then the word From
and Sender and this will be text there. Now I could just leave that there and that will be the
text of the reminder. But I could also edit it. So if I want to leave a note to myself or I want
to say something different than the subject line I could actually change it here. I'll demonstrate
that when I run this. Now we've got three buttons. One says 4 PM today, another 4 hours from now,
and another is Cancel. The idea here is for me 4 PM is a good time to get back to email
that I may not have had time to answer earlier in the day. It may be a different time for you.
Four hours from now allows me to snooze it past that. Maybe it's past 4 PM already or maybe I
want to get to it sooner than 4 PM. So I've got two different types of times there. So next I'm
going to take which button I click and calculate a time for the reminder to show me a notification.
So if I selected 4 PM today it's going to take the current date and then it's going to set
the hour to 16, which is 4 PM. Then minutes and seconds to zero. So if it's January 15th at 10:15
AM it's going to take January 15th but reset the hour to 4 PM, minutes to zero,
seconds to zero. On the other hand if I chose 4 hours from now then it simply is going to add 4
hours to the current time. If I chose Cancel then it's actually going to return. It's going to quit
the entire thing and stop doing what it's doing. So even if I have multiple things selected if I
choose Cancel for any of them it will just cancel out. That will prevent me from making a mistake.
I'm not locked in to actually setting the reminder once I've triggered this keyboard shortcut.
Now I want to get the title of the reminder. Now before I passed into the dialogue the Subject,
the word From, and the word Sender. Now that will actually come out of the dialogue
and I would put it into Reminder Title. But I also have the opportunity to change that text
while it's in the dialogue. Next I'm going to create a new reminder object.
I'm going to set its name to the Reminder Title. In the body I'm going to add something special.
I'm going to use the term message colon slash slash and then surround it by less
than and greater than symbols I'm going to put that message ID. It turns out that this will
create a link in Reminders that then will open up that email message. It's identifying it by
ID so it doesn't matter if it's still in the Inbox, if it's in an Archive folder, or some
other folder. Then we're going to add it to our Reminders List called email Snooze. So that's
the name of the Reminders list that I created to hold these. So you want to make sure you've
created a Reminders List with that exact name or any name that you choose as long as it matches.
Now the last thing the script does is optional. I didn't want to have to Archive the message
after activating this script. I wanted to automatically Archive. There are several
different ways to do this. But the one that seemed to work the best is simply to trigger
the Archive shortcut in Mail. So this is just going to simulate a command control a,
which will Archive the messages that are selected. Now that's because my workflow is to Archive every
email I get. If you have a different workflow like you file each email message into a specific
Mailbox, or maybe you leave them in your Inbox then you're going to want to leave this out.
Now let's Save this and I'm going to save it as Mail Snooze
and since it's a QuickAction I don't get a choice to where it is saved. It's going to save to the
Special Services folder in my Library folder. Now in the Mail app if I go to Mail, Services I'll see
Mail Snooze. Before we use it let's assign a keyboard shortcut to it. So in System
Preferences I'm going to go to Keyboard and then Shortcuts and then App Shortcuts and
add a new one. I'm going to set the Application to just Main and I'm going to give it the exact
name of the menu item which is Mail Snooze. This must match what you see in the Menu Bar exactly.
The keyboard shortcut I'm going to use Control Command and A, just like archive but I'm going
to Shift. So now I have two keyboard commands that are kind of similar Control Command
and A will archive a message. But adding Shift to it will also add this reminder. So now that I've
added that I can check in Mail, Services and I can see that the keyboard shortcut has been added.
So let's try it out. I'll do Shift Control Command and A
and you could see it comes up with my dialogue here. There's the Title and it says From and
then who it's from. I can choose 4 PM today which is the default so I can just hit return,
or 4 hours from now, or Cancel. I'll choose the default by just hitting Return. Now the thing I
haven't done is set permissions. So, Mail app wants to control reminders; is that okay. Yes.
Now Mail app wants to access reminders. OK. Now the last part is Mail app wants to control
system events. Remember to send that keyboard shortcut. So I'll hit OK.
Now I get an error because you can't actually just OK that permission. You have to go and set it up
inside of System Preferences on your own. So let's do that. I'm going to go to Security and
Privacy and then Accessibility. I'm going to Unlock and here you can see I have to enable
Mail app. So now it will work the next time I do it which we'll test out in a minute here.
But first let's see if the first part of that script works. It should have created a reminder.
I'll go to Reminders, Email Snooze. There it is. There's the name and the note has this link in it.
You can see it's set to today, 4 PM. I'm going to select it and delete it. Let's give it another try
now that we've granted permissions for keyboard control. So I'll try the same keyboard shortcut
again. It's going to ask me here what I want to call it. But let's rename it. You can see it's
already selected there. So I can just rename it to something that might make more sense to me.
This time I'll go to 4 hours from now, and you could see it archived it fine this time now
that I've given it permissions. Here in my email snooze reminders you could see it has set the time
for the reminder for exactly four hours from now and there's the link. Now let's try the link out.
Remember, in Mail now it's no longer in the Inbox. It's been Archived. So if I click here to select
the reminder you can see now this is a link. I can click on it. It will launch Mail and you could see
that message has been brought up even though it's no longer in the Inbox. So now I can respond to
it. Now that I've taken care of this I can click here to indicate that I'm done with this reminder.
So I'll include the full script to this at this post
at MacMost.com so you can easily copy and paste this into your own Automator action
and modify it to suit your needs. Hopefully, in addition to being able to use this as
is you can use parts of this to accomplish your own tasks in other Automator workflows.