orgmode for mail

使用orgmode越来越顺手,于是用它替换markdown作为写HTML邮件的首选。配置如下:

(defun wl-message-goto-body-end ()
  "Go to the end of message body.  Before attachment part."
  (or (save-excursion
        (when (re-search-forward
               "^<#part .+ filename=.+ disposition=attachment>$"
               nil
               t)
          (forward-line -1)
          (end-of-line)
          (point)))
      (point-max)))

(defun wl-org-export-region-as-html-string (beg end)
  (interactive "r")
  (save-excursion
    (org-export-region-as-html beg end t 'string)))

(defun wl-mail-org2html-region (beg end)
  (interactive "r")
  (save-excursion
    (let ((html-txt (wl-org-export-region-as-html-string beg end)))
      (goto-char end)
      (message "%s" end)
      (insert "<#part type=text/html>n<html>n<head>n<title>HTML version of email</title>n</head>n<body>")
      (insert html-txt)
      (insert "n</body>n</html>n<#/multipart>n")
      (goto-char beg)
      (insert "<#multipart type=alternative>n"))))

(defun wl-mail-org2html-message-body ()
  (interactive)
  (save-excursion
    (message-goto-body)
    (wl-mail-org2html-region (point) (wl-message-goto-body-end))))

(add-hook 'message-send-hook 'wl-mail-org2html-message-body)

One thought on “orgmode for mail

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据