Alex headshot

AlBlue’s Blog

Macs, Modularity and More

Mail.app message URLs and iCal

2009, mac, tip

Mail.app responds to a message: URL protocol; if you specify a Message-Id (as seen by the message's headers; View->Message>Long Headers), then it will open up the message in the Mail application. For example, here's some headers from an (old) message:

X-Apple-Mail-Remote-Attachments: YES
X-Apple-Mail-Signature: SKIP_SIGNATURE
Content-Type: text/html;charset=US-ASCII
Message-Id: <2929BE19-D00D-BEEF-ABDC-AB0CF776910B@gmail.com>
Content-Transfer-Encoding: 7bit
X-Apple-Windows-Friendly: 1
From: Alex Blewitt <...@gmail.com>
Subject: Test

For the purposes of this discussion, the Message-Id header (<2929BE19-D00D-BEEF-ABDC-AB0CF776910B@gmail.com>) is the important part. To open this message up in Mail.app, regardless of which folder this mail message happens to be in, we can invoke an open command from Terminal (or any other app capable of launching a document based on a URL) that will invoke it, with message:<2929BE19-D00D-BEEF-ABDC-AB0CF776910B@gmail.com>. Mail will then display this message, which can be handy for replying to specific messages, or attaching to reminders. (If you run this from Terminal, due to Message IDs often including < and > characters, then you might need to wrap it in 'quotes' to avoid shell interpretation.)

This can also be hooked into iCal, although not in an obvious way. If you edit an entry (or create one), you'll see a url field. This is typically used to refer to web-based resources associated with an event. You can also use it to fire up a mail message, either by constructing the message ID yourself, or by dragging-and-dropping the message onto the URL field. For whatever reason, you can't drag-n-drop it onto the event directly; you need to open up the event info window first.