7 days of unlimited WordPress themes, plugins & graphics - for free!* Unlimited asset downloads! Start 7-Day Free Trial
  1. Computer Skills
  2. Automation

Effortless Paperless Nirvana With Mail, Hazel and Evernote

Scroll to top
Read Time: 8 mins
This post is part of a series called Going Paperless.
Use HelloSign to Get Documents Signed Online
How to Convert & Edit PDF Documents in Microsoft Word

With the relentless onslaught of the digital era, paperless systems have been gaining increasing traction and relevance. While the benefits are undeniable, there are times when workflows are far from frictionless and often tedious, making them less appealing.

There is hope however and in this screencast I'll teach you how to leverage apps such as Mail, Hazel and Evernote to automate at least one aspect of your paperless workflow.


You'll need:

The Mail Rule

Effortless Paperless Nirvana With Mail, Hazel and Evernote

Step 1

The initial step is to set up a mail rule that will filter any email from your utility company. To do that, simply click on Mail > Preferences and then choose the Rules tab.

Click on Add Rule, give the rule a meaningful name and then choose some conditions. If you need to assign more than one condition, then take note if you want to match all, or any, since this will affect how emails are matched.

When choosing more than one condition, take note if matching all or any.

Once you're satisfied with your conditions, it's time to assign some actions. For the first action, choose to Mark as Read. For the final action, choose Run Applescript and then from the drop down list of available scripts choose Open in Finder.

Step 2

Now that you have the finder open in the correct location, open AppleScript Editor. You can find AppleScript Editor in the Utilities folder or optionally summon spotlight and type AppleScript Editor.

Paste in the following code and then save the script in /Users/YOUR USERNAME/Library/Application Scripts/com.apple.mail/

Code Breakdown

In order to adapt the code to suit your needs, it's essential you understand it, so let's break it down.

  • Lines 2-3 & 32-33 are simple boilerplate code. Each AppleScript that is to be run by a Mail rule needs this. The actual script that performs actions with the matched messages is placed inside this block;
  • Line 5 starts the tell block, instructing (telling) Mail app to perform some actions;
  • Line 7 assigns the Downloads folder to a variable. This will later be used as the location to which attachments are saved;
  • Lines 9-29 is a repeat block. Actions within will be repeated for every email message matched by the mail rule;
  • Line 11 assigns the emails subject to a variable, this will later be used to rename the attachment;
  • Lines 13-26 is another repeat block. Actions within will be repeated for every attachment found in each individual message;
  • Line 17 assigns the original attachment filename to another variable;
  • Line 18 renames the attachment with the following pattern: Utility Company | Emails Subject | Original attachment filename;
  • Lines 21-25, a try block, tries and saves the attachment in the Downloads folder. If it fails an error message will be triggered.
  • Line 28 moves the email to a final mailbox, in this case named Bills.

Step 3

After having saved the above script in the correct location, you should now be able to select it from the drop down list in the Run AppleScript action; do so and then click OK and finally click Apply.

Creating The Hazel Rule

Hazel is a preference pane utility that monitors folders of your choosing and performs actions on files and folders when criteria you defined are met.

Effortless Paperless Nirvana With Mail, Hazel and Evernote

Step 1

Assuming you've already downloaded and installed Hazel, you'll need to add the Downloads folder to the Folders list. To do so, open System Preferences > Hazel and then simply drag it in from a Finder window or alternatively, click + and select it.

Before going any further, it's important to pause rule processing. This will ensure that no rules are processed until you're confident the rules you set up are correct. To pause rule processing, right click (Ctrl + click) on Downloads from the folder list and select Pause "Downloads rules".

Step 2

Now that Hazel is watching the Downloads folder, you need to define some rules. In Hazel, rules are defined in a similar manner as they are in Mail. You set some conditions to match and then some actions to perform.

Under Rules, click + to add a new rule. Give it a name and then add your first condition. Choose Kind then is and finally select PDF. This will ensure that Hazel will only match PDF files. If your utility company sends you your bills in any other format, then change this appropriately.

For the second condition we want to make sure that Hazel will search for a file with a name that matches the pattern defined in the Mail rule above; so choose Name, then matches and finally in the next field, type the tag assigned above (Utility company) followed by a "|" character, then drag in the Anything token, followed by another "|" and finally another Anything token.

Step 3

Now that you have defined some conditions, you need to set up some actions. For the first action, choose Run AppleScript, leave the default embedded script selected and then click on edit script. Paste the following code in the modal window, click on compile and if no errors are present, click away from the modal window.

The compile button in Hazel. If any error is detected, it will appear next to the button.

Code Breakdown

As before, let's analyse the code in order to get a better understanding of what is happening:

  • Line 1 starts the tell block which instructs Finder to perform some actions;
  • Line 3 performs 2 actions. It starts off by storing AppleScripts text item delimiters (by default it's a space) in a variable and then changing the text item delimiters to a "|";
  • Line 4 assigns the matched filename to a variable. Since text item delimiters were changed to a "|", and given the filenames pattern, this variable now holds 3 text items;
  • Line 11 changes the matched files name to the original attachment name. This value is extracted from text item 3;
  • Lines 12-27 is a try block. AppleScript tries to perform the actions contained within and in case of an error, displays a message;
  • Lines 14 and 15, tell Evernote to activate. This will launch Evernote and bring it to the front;
  • Line 16 creates a 15 second pause, giving Evernote time to launch properly before attempting to create a new note;
  • Lines 20-22 create a new note in the Receipts notebook. The notes title is the emails subject (text item 2) and the note is tagged with the utility companies name (text item 1). The attachment is added to the note too;
  • Line 28 resets AppleScripts text item delimiter to default.

Step 4

For the final action, choose Move to folder and then select Trash. This will ensure that once your bill base been successfully uploaded to Evernote, it doesn't stick around creating clutter on your Mac. Finally click OK.

Now that you've successfully created a rule to match your file, it's time to let Hazel perform its magic, so you'll need to unpause rule processing. Just as before, right click on Downloads in the folder list and this time, selected Resume "Downloads" Rules.

Since Hazel can take a while before running rules the first time, right click on Downloads once again and choose Run Rules Now. If all went according to plan, Hazel should upload the file to Evernote and then move it to the Trash.


In this tutorial we've covered a few basic automation concepts that will hopefully aid in streamlining your paperless workflow. These concepts however are not limited to this small scope, but rather can serve as building blocks for more complex and ambitious workflows.

Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Computer Skills tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.