Create Yojimbo Note: Applescript for Apple Mail
My last few postings have all been tech related. Since most of my history related postings are also Asian history related postings, I post those increasingly at Frog in a Well. I’ve been in a hacking mood in the last few weeks, especially since I’ve been working on some new projects at Frog in a Well in my spare time. My last two scripts are essentially shortcuts for creating iCal To-Dos. The first provides a fast way to use Quicksilver to create To-do items without leaving whatever application you are working in. The second provides a way for you to email yourself To-dos that then automatically tell iCal to create a To-Do with content from the email.
The script below is not related to To-Dos but is also aiming to increase my organization a bit. I use a program called Yojimbo (it is a great program but I think the title and its Karate Kid icon are both cheesy) made by Bare Bones, the same people who make BBEdit, the essential text editor for web programmers and coders of all stripes. Yojimbo is a program which keeps snippets of notes, web passwords, serial numbers, and best of all: you can drag and drop any web page you are viewing onto a little tab it keeps at the side of the screen and Yojimbo will download a static copy of the web-page and store it along with all your other notes. Great for when you think you might be away from the internet and want to keep the content handy for later searching.
Sometimes I’m away from my laptop, and as in the case of emailing myself To-Dos that I want created automatically in iCal, there are times I jot down notes from something and want to email myself those notes. It would then be nice for Mail to automatically detect those emails, and create a new Note in Yojimbo with the appropriate title and contents. I hacked together a little script which does just that.
First create a mail filter in Apple Mail that recognizes an incoming email with the prefix “NOTES:”, runs the script, marks the message read and moves it to a folder (in my case called “Reference”). Something like this:

The Applescript you can point it to can be downloaded here. The raw text of the Applescript is below:
using terms from application “Mail”
on perform mail action with messages theMessages for rule theRule
tell application “Mail”
repeat with eachMessage in theMessages
set emailsubject to subject of eachMessage
set theContent to content of eachMessage
set emailsubject to text 7 thru (the length of emailsubject) of emailsubject
try
tell application “Yojimbo”
set newnote to (make new note item with contents theContent)
tell newnote
set name to emailsubject
end tell
end tell
end try
end repeat
end tell
end perform mail action with messages
end using terms from

December 14th, 2006 at 4:56
[...] Konrad Lawson has written an applescript which will cleverly pick out the text of an email you have sent to yourself and use it to create a note in Yojimbo. [...]
November 19th, 2007 at 15:35
Hello,
I just found your handy little script through an old HawkWings article. I’m using it with Leopard, which seems to work fine, except that it doesn’t read the subject as the note title, but just creates an ‘untitled’ note. Are you aware of a quick fix for this?
John
November 19th, 2007 at 18:27
Thanks for letting me know. Unfortunately, I don’t have a copy of Lepoard yet, so I can’t test for a fix. Sorry about that.
April 2nd, 2008 at 16:13
[...] Here’s what task capture rule in Mail.app looks like: The MailAction.applescript pictured is included with OmniFocus. With this rule, any email that comes to the ToDo POP account is automatically passed along to my OmniFocus inbox to be processed. The rule for Yojimbo looks identical, except that is is for my Yojimbo POP account, and runs a script that I found here. [...]