org-mac-message.el – linking to messages in OS X

Table of Contents

{Back to Worg's contibutions index}

The org-mac-message.el library provides various methods for linking to OS X messages from within org-mode.


  • To load org-mac-message.el by default:
    (add-to-list 'org-modules 'org-mac-message)

    Note that org-modules must be set before org-mode is loaded.

  • Configure the default account you would like to use:
    (setq org-mac-mail-account "account")


org-mac-message.el will create links with the format:


When followed, these links will open the relevant message in

New functions

Inserts formatted list of links at point to selected messages in

To ensure backwards compatability, (org-mac-message-insert-link) is aliased to this function.

(org-mac-message-insert-flagged (org-buffer org-heading))
Asks for an org buffer and heading within it. If the heading does not exist, create it at `point-max'.

Warning: the next step is destructive

Search for flagged mail in and insert a formatted list. Delete all message:// links within the heading's first level. of links under the specified heading.

If you have Growl installed, notifications will inform you of the progress of the AppleScript search.

(org-mac-message-get-links (select-or-flag)
Searches for selected messages or flagged messages in the account specified by org-mac-mail-account. Creates a formatted list of these links and copies them to the kill-ring.

Examples of usage

The following function will search the account Gmail for flagged messages and insert them in the org-mode buffer under the heading Flagged mail.

(defun my-mail-import ()
  (let ((org-mac-mail-account "Gmail"))
    (org-mac-message-insert-flagged "" "Flagged mail")))

This function could then be linked to from an org-mode buffer:


or set as a command in the agenda dispatcher:

(setq org-agenda custom-commands
      '(("F" "Import links to flagged mail" agenda ""

Documentation from the website (either in its HTML format or in its Org format) is licensed under the GNU Free Documentation License version 1.3 or later. The code examples and css stylesheets are licensed under the GNU General Public License v3 or later.