Mac Mail Scripting: Send Message to Evernote

I’ve been trying to replicate the “Send to Evernote” button that gets installed with Microsoft Outlook 2013 at my work to also be an option for my Mac Mail app. My first stab was to see if there was some sort of toolbar button I could use, nope. Evernote hasn’t gotten that far yet.

I looked around Automator, hoping, and saw nothing for Evernote in Automator. So then I thought I would turn to AppleScript. I opened up the AppleScript editor, then opened up the AppleScript Dictionaries for Mail.app and Evernote.app. Through a series of web searches I figured out two main things:

1) How to extract the sender, subject, and content of an email in AppleScript
2) How to create a new Evernote Note with the details gained from Step 1

So, here’s how I did it:

Open up AppleScript Editor and copy this code into it:


tell application "Mail"
set theSelection to selection
set theMessage to item 1 of theSelection
set theText to content of theMessage
set theSubject to sender of theMessage & " : " & subject of theMessage
tell application id "com.evernote.Evernote"
activate
create note with text theText title theSubject tags "mail"
end tell
delete theMessage
end tell

Then you need to do some clever things in AppleScript Editor to get this all to work properly:

1) In AppleScript Editor, open Properties.
2) Put a checkmark in “Show Script menu in menu bar”
3) Close the Properties dialog box
4) Save your AppleScript to your Desktop called “Send Email to Evernote.scpt” and save it.

Now you have to install your script:

1) Open a finder window, arrange it so that you can see the finder window comfortably and also see your script on your Desktop.
2) Navigate to your Macintosh HD, then Library, then Scripts, then Mail Scripts.
3) Click and drag the “Send Email to Evernote.scpt” into the Mail Scripts finder window. Your Mac will stop you, ask you to Authenticate, so do that. The file should copy into this folder.

Now when you go back to Mac Mail, you’ll notice a little script icon in the menubar. Click on the Script menu bar item, then click on “Mail Scripts” and then click on Send Email to Evernote. Your Mail message will disappear. The message has gone to the Trash, and the text of it is now in your default folder in Evernote, with the senders name, a space, a colon, a space, and the subject of the message as the title of the note, with the contents of the note set to be the contents of your note itself.

That was enough for me. Please note, this script creates notes and deletes mail. There are no guarantees that this script will work for you. I don’t really support it as I barely understand AppleScript as it is. It works with just one message at a time and it’ll probably butcher attachments and I have no idea what HTML messages will do if subjected to this sort of treatment. An epic-level “Your Mileage May Vary”, so you know, be careful.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.