50Ply Blog

Building Things

Mail.app Email Snooze

| Comments

Email Snooze: The Concept

You’re in the middle of something, and an email comes in. This email is important, and it needs your attention, but not right now. How do you make sure you don’t forget this email? Here’s the answer: Give your inbox a snooze button!

Here’s how it works: An important email comes in–your boss needs an update on your project, but right now you’ve got to stay focused on your task. You press a few keys (Control-Space Command-Apostrophe) and you get back to work. Now, the email is moved to your “Snoozed” folder and an alert is added to your calendar to remind you about that email in 30 minutes.

Email Snooze: How to get it

I was inspired to do this by a similar feature that can be added to gmail. I looked but couldn’t find the equivalent for Mail.app (the OSX email client), so I wrote it myself.

You’ll need the excellent and free QuickSilver application so you can create a hot key that executes the SnoozeMail script. Install that now if you don’t already have it. You won’t need to install any of the QuickSilver plugins to make SnoozeMail work.

Next, launch the AppleScript Editor and copy-paste the following code into the editor window:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
tell application "Mail"
  set theSelectedMessages to selection
  set theMessage to item 1 of theSelectedMessages
  set theSubject to subject of theMessage
  set theMailbox to "Snoozed"
  set theAccount to "Gmail"
  
  move the theMessage to mailbox theMailbox of account theAccount
end tell

tell application "iCal"
  tell calendar "Delayed Mail"
      set theCurrentDate to current date
      set fireDate to (theCurrentDate + 30 * minutes)
      set theSubject to "Follow up on delayed mail '" & theSubject & "'"
      set theEvent to make new event at end with properties {description:"Delayed Mail", summary:theSubject, start date:fireDate}
      tell theEvent
          make new display alarm at end with properties {trigger interval:-1}
      end tell
  end tell
end tell

If Mail.app is fetching your mail from an account other than Gmail, then you will need to edit the 6th line to set theAccount to the name of your email account. You can find the name of your email account by opening Mail, then opening the Mail menu, and then selecting Preferences. Next, click the accounts button and copy the account name from the Description box into the SnoozeMail script. For example, if my Description box had the text “brian@50ply.com” in it, I would edit the 6th line of SnoozeMail to say:

1
set theAccount to "brian@50ply.com"

Next, you need to create the mail folder and the calendar that SnoozeMail will be using. Create a new mail folder called “Snoozed” and create a new calendar called “Delayed Mail”. Select one of your emails, then switch over to the AppleScript editor and click on the Run button to test your script. If anything goes wrong, AppleScript should give you a helpful error message. If the email is successfully moved to your new Snoozed folder, and you see a new event in your Delayed Mail calendar, then you’re ready to move on!

Save the script into your Documents folder, and call it SnoozeMail.

After you’ve saved the script, press Control-Space Command-Apostrophe to activate QuickSilver’s configuration screen. Then select Triggers from the toolbar at the top of the window. Click on the small plus sign in the bottom-left of the window to create a new trigger. Select Hot Key from the menu.

click triggers and then click the plus to make a new trigger

Type “SnoozeMail” and QuickSilver should auto-complete the name of the script you saved. If QuickSilver can’t find it, try closing and re-opening QuickSilver to force it to search your computer again.

Click on the ‘i’ in the bottom-right of the window and then click in the Hot Key box to create the hot key that will activate this script. I use Command-Apostrophe. Next, select the scope button and pick “Enabled in selected applications” from the drop-down menu. Type “Mail” in the box and press enter.

Congrats! Now you should be able to snooze an email directly in Mail by selecting it and pressing Control-Space Command-Apostrophe! I hope you enjoy this as much as I have.

Comments