This is a small variation of the 2019 post on linking to emails from Org mode using Thunderbird, where instead we show how to open the message:// links with mu4e if active, or the fastmail web-app if it is not.

You might remember that message://msg-id-here links represent one of the better ways to link to emails from your PKM systems.

Code

Below is the code. Let me know in the comments if you have any questions.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
(defun org-message-mu4e-fastmail-open (slash-message-id)
  "Handler for org-link-set-parameters that follows a standard message:// link
     using mu4e if active, or the fastmail web-app if not."
  ;; remove any / at the start of slash-message-id to create real message-id
  (let ((message-id
         (replace-regexp-in-string (rx bos (* "/"))
                                   ""
                                   slash-message-id)))
    (if (fboundp 'mu4e-view-message-with-message-id)       ;; this will be the case only if mu4e is active
        (mu4e-view-message-with-message-id message-id)
        (browse-url (concat "https://app.fastmail.com/mail/search:msgid:" (url-hexify-string message-id))))))

;; on message://aoeu link, this will call handler with //aoeu
(org-link-set-parameters "message" :follow #'org-message-mu4e-fastmail-open)