Vikram Mandyam

I write about software, cloud, books, emacs, productivity, photography and fitness

Capturing and sending minutes of meeting in Emacs

[Vikram Mandyam] / 2019-02-25


I use Emacs for everything, including writing minutes of any meeting I attend. I use Org Mode for this as its markup syntax makes it easy and quick for capturing content.

Unfortunately, one has to also send over the minutes in an email to others and this involves a program other than Emacs most of the times. (those using mu4e or similar can consider themselves lucky!)

In such cases, I had to manually copy the contents of the org file to the external email client. This also involves more manual work of formatting the pasted content again, in the said client. Since most email clients support HTML, one could export the org file to HTML and then paste it in to avoid the formatting of the pasted content again.

I wanted to eliminate this manual step of exporting and then pasting it in. So, I whipped the following piece of elisp to help me.

With this, it automatically exports the org content to a new email window in outlook ready to be sent.

(defvar outlook-new-message "")
(setq outlook-new-message "")
(defvar outlook-new-message-format "")
(setq outlook-new-message-format
      "tell application \"Microsoft Outlook\"\n\
	set newMessage to make new outgoing message\n\
	set the content of newMessage to %s \n\
	open newMessage\n\
       end tell")

(defun org-get-html-content ()
  (with-current-buffer
      (org-export-to-buffer
	  'html "*html export*"
	nil 'subtreep nil nil nil nil)
    (goto-char (point-min))
    (setq outlook-new-message
	  (format
	   outlook-new-message-format
	   (prin1-to-string (buffer-string)))))
  (kill-buffer "*html export*"))

(defun vm/org-export-to-outlook ()
  (interactive)
  (org-get-html-content)
  (delete-window)
  (let ((my-path (make-temp-file "foo")))
    (write-region outlook-new-message nil my-path)
    (shell-command (format "osascript %s" my-path)))
  (delete-file my-path))

With this, I just take notes in Org Mode within Emacs and when I am ready, I point to the subtree heading and then invoke the function vm/org-export-to-outlook

Note that this only works with outlook on MacOS. But it should not be very difficult to make something for other clients and/or OSes.

There are a lot of things that can be done to make this even better, for instance remove the table of contents, and validate links. Perhaps, these improvements are reserved for some other day…