I keep track of my activity in an org-file. The latest status is always under the heading "Current" which I usually just cut and paste into IRC for our weekly meetings. However we are now asked to send the status out ahead of time as an email. I'm trying to work out the best way to create a draft email based on the contents of the an org subtree. Currently I have a babel snippet that will fill the kill-ring but that seems a little hackish. It would be nice to create a complete draft together with address and subject lines.
You could write a function that copies the subtree to the kill ring, creates a new buffer in
message-mode, inserts a couple of lines and pastes the contents of the kill ring, like so:
(defun my-status-as-email () (interactive) ;; TODO: copy org subtree to kill ring ;; ... (set-buffer (get-buffer-create "*draft*")) (message-mode) (insert "From: me\n") (insert "To: you\n") (insert "Subject: my status\n") (insert "--text follows this line--\n") (yank) (pop-to-buffer-same-window (current-buffer)))
Alternatively and more elegantly, use
(progn (compose-mail "email@example.com" "my subject") (insert "my awesome summary:") (yank) ...)
I'm accepting @rekado's answer as he got me there. But here is the org-babel snippet I'm now using for sake of completeness:
#+name: draft-status-email #+begin_src emacs-lisp (let ((end-of-week (chomp (shell-command-to-string "date --date='09:00 next Fri' +'%b. %e %Y'")))) (save-excursion (goto-char (point-min)) (re-search-forward "** Current") (org-copy-subtree) (kill-whole-line) (insert (format "** Team Email %s\n" (format-time-string "%e/%m/%Y")))) (compose-mail "firstname.lastname@example.org" (format "[weekly] week ending %s" end-of-week) nil t) (insert "Summary of activity:\n") (yank 2)) #+end_src