Skip to content

Instantly share code, notes, and snippets.

@RyanGreenup
Created May 3, 2020 01:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanGreenup/d131df62895500a0e1c93242d3b4c4ba to your computer and use it in GitHub Desktop.
Save RyanGreenup/d131df62895500a0e1c93242d3b4c4ba to your computer and use it in GitHub Desktop.
Export Email from Emacs with Formatting

Export Email from Emacs

How to export email from Emacs:

Define a function to export email:

(defun export-email ()
  (interactive)
  (message "Beginning Email Export")
  (yank-visible-org-buffer)
  (call-eml)
)


Decide on how to yank the text:

(defun yank-visible-org-buffer ()
    (interactive)
    (goto-char (point-min))
    (mark-page)
    ;; (evil-yank (point-min) (point-max))
    (org-copy-visible (point-min) (point-max))
  )

Use seperate bash script to export the email:

(defun call-eml ()
    (async-shell-command (format "~/bin/eml -o"))
  )

Get a custom style sheet like this one and Write a bashscript to do some magic pandoc:

# Take the Clipboard
xclip -o -selection clipboard >> myemail

# Use Pandoc
pandoc -s --toc --self-contained --mathml $EmailFile -o myemail.html

# Embed a style sheet
    # I do the style sheet like this because sometimes -C fails
echo "<style>" >> myemail.html
cat ~/Dropbox/profiles/Emacs/org-css/github-org.css >> myemail.html
echo "</style>" >> myemail.html
cat myemail.html | xclip -selection clipboard

# Import the file into Thunderbird
thunderbird --compose "message=myemail.html,format='html'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment