Org Exporting and Emailing

Seth Mason

Thus, I really liked John Kitchin's post about sending email with org. It was almost perfect (to me). The only thing it didn't do was format the content before exporting. It just sent it out as plain org.

Thanks to his hard work, I just had to add a few bits to come up with this. Now I can get the cool line blocks around my code and execute the org-babel blocks in my headings before they get sent out. This is very helpful when sending out snippets of code and random command line effluvia.

(defunemail-heading-after-export(backend&optionalplist)"Send the current org-mode heading as the body of an email, after convertingit to the given backend."(interactive)(setq*email-heading-point*(set-marker(make-marker)(point)))(save-excursion(org-mark-subtree)(let((TO(org-entry-get(point)"TO"t))(SUBJECT(nth4(org-heading-components)))(continuenil)(switch-functionnil)(yank-actionnil)(send-actions'((email-send-action.nil)))(return-action'(email-heading-return))(plist`(:with-tocnil,@plist)));; we do not want the mark to interfere with export(deactivate-mark)(message(format"%s"plist))(org-export-to-bufferbackend"*org-to-email*"niltniltplistnil)(switch-to-buffer"*org-to-email*")(let((content(buffer-substring(point-min)(point-max))))(compose-mailTOSUBJECTnilcontinueswitch-functionyank-actionsend-actionsreturn-action)(message-goto-body)(insertcontent)(ifTO(message-goto-body)(message-goto-to))))))