One of the tools included as part of iOS6 and OS 10.8 is a simple but useful note taking app, unsurprisingly named 'Notes', which is also part of the iCould service and can be synced between devices over the internet.

I've used Notes lightly since it appears, primary to jot things down when I'm travelling (I used it a lot at Worldcon), and as a shared clipboard to move URLs and small snippets of text between my Mac and the iPad.

What isn't readily obvious when using the application in either guise, or the iCloud web service, is how the notes are stored.

It becomes apparent, however, if you use a third-party mail client to access your iCloud email account. There is a 'Notes' folder, hidden when viewed in Mail.app, which contains, as you might expect, your notes in standard e-mail message form.

Okay, so we can read notes over IMAP, can we write them? Editing existing ones works as expected, but just saving a new email message into the folder doesn't - the message is visible to the IMAP client, but note to the Notes app.

So lets look a little closer at the headers on the notes from Notes:

Subject: An uninteresting note
From: Me <me@example.com>
X-Universally-Unique-Identifier: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Content-Type: text/html;
        charset=utf-8
X-Uniform-Type-Identifier: com.apple.mail-note
Message-Id: <XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX@me.com>
Date: Wed, 25 Jul 2012 23:43:09 +0100
X-Mail-Created-Date: Wed, 25 Jul 2012 23:43:09 +0100
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (1.0)

Mostly what I would expect, apart from the X-Universally-Unique-Identifier and X-Uniform-Type-Identifier headers, which turn out to be the magic trick. Create a new message with those headers (with a new UUID in the unique-identifier one), and hey presto, it appears on iCloud and in Notes.

With a little bit of help from offlineimap and some shell glue it is not particularly hard to use this mechanism to create new notes, or edit existing ones, from the command line.

Posted Fri 11 Jan 2013 18:18:17 GMT Tags: