org-mime
can be used to send HTML email using Org-mode HTML export.
This approximates a WYSiWYG HTML mail editor from within Emacs, and can be useful for sending tables, notified source code, and inline images in email.
org-mime
exposes two functions
org-mime-htmlize is an interactive Lisp function in `org-mime.el'. (org-mime-htmlize ARG) Export a portion of an email body composed using `mml-mode' to html using `org-mode'. If called with an active region only export that region, otherwise export the entire body.
org-mime-org-buffer-htmlize is an interactive Lisp function in `org-mime.el'. (org-mime-org-buffer-htmlize) Export the current org-mode buffer to HTML using `org-export-as-html' and package the results into an email handling with appropriate MIME encoding.
The following key bindings are suggested, which bind the C-c M-o
key
sequence to the appropriate org-mime
function in both email and
Org-mode buffers.
(add-hook 'message-mode-hook (lambda () (local-set-key "\C-c\M-o" 'org-mime-htmlize))) (add-hook 'org-mode-hook (lambda () (local-set-key "\C-c\M-o" 'org-mime-org-buffer-htmlize)))
Email clients will often strip all global CSS from email messages. In the case of web-based email readers this is essential in order to protect the CSS of the containing web site. To ensure that your CSS styles are rendered correctly they must be included in the actual body of the elements to which they apply.
The `org-mime-html-hook' allows for the insertion of these important CSS elements into the resulting HTML before mime encoding. The following are some possible uses of this hook.
(add-hook 'org-mime-html-hook (lambda () (org-mime-change-element-style "pre" (format "color: %s; background-color: %s; padding: 0.5em;" "#E6E1DC" "#232323"))))
(add-hook 'org-mime-html-hook (lambda () (org-mime-change-element-style "blockquote" "border-left: 2px solid gray; padding-left: 4px;")))
For other customization options see the org-mime
customization
group.
org-mime
was developed by Eric Schulte with much-appreciated help
and discussion from everyone on the "using orgmode to send html mail"
thread especially David Maus.