[gnu.emacs.vm.info] Re: sending html mail using VM
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
VM |
Fix Released
|
Wishlist
|
Uday Reddy |
Bug Description
affects viewmail
From: Eric Schulte <email address hidden>
Organization: schulte
Newsgroups: gnu.emacs.vm.info
Date: Thu, 10 Jan 2008 18:36:28 -0800
Subject: Re: sending html mail using VM
Eric Schulte <email address hidden> writes:
> <email address hidden> writes:
>
>> Eric Schulte <email address hidden> writes:
>>
>>> Like it or not most of the people I email with (especially at work),
>>> use mail readers that work best with HTML formatted mail.
>>>
>>> I use org-mode for most of my note taking, and there are many times
>>> when I would like to send formatted mail with tables, bold text
>>> etc... to these people. Their mail readers don't use fixed width
>>> fonts, so my tables display as garbage. However I can export my
>>> org-mode notes to very nice html documents.
>>>
>>> Is there a way for me to
>>>
>>> 1. compose mail in org-mode
>>> 2. on sending convert the mail to html
>>> 3. send the mail as a mime-type text/html message using VM
>>>
>>> I have just tried to send some simple html mail using vm just by
>>> adding a "Content-Type:" header to the top of the mail, but that
>>> wasn't sufficient.
>>
>> Two headers are required, Mime-Version and Content-Type, e.g.
>>
>> ,----
>> | MIME-Version: 1.0
>> | Content-Type: text/html; charset=
>> `----
>>
>> This should be sufficient.
>>
>> The even the charset may be dropped.
>>
>> From an org-mode buffer use something like ...
>>
>> (defun org-mode-2-vm-mail ()
>> (let ((html-buffer (get-buffer-create "*html*")))
>> (org-export-as-html nil nil nil html-buffer nil)
>> (vm-mail)
>> (goto-char (point-min))
>> (insert "MIME-Version: 1.0\n")
>> (insert "Content-Type: text/html")
>> (search-forward mail-header-
>> (delete-region (point) (point-max))
>> (insert "\n")
>> (insert-
>> (kill-buffer html-buffer)
>> (message "Add the headers...")))
>>
>> It could be better, e.g. org-mode just for the body and normal
>> vm-mail-mode on top, but I am not sure how this should interact.
>>
>> Robert.
>
> Thanks for the code!
>
> Actually there is already a way to have org-mode active while
> composing text emails (info "(org)orgstruct
> people who like the way org indents lists, etc... This intercepts the
> "\C-c\C-c" command and uses it for org things or passes it to the
> major mode depending on where in the buffer you lie. I'm working on
> changing the behavior of orgstruct-mode so that if you use "\C-c\C-c"
> with a prefix command in a mail buffer, it will send the body as html.
> Hopefully your code will complete what I've got so far.
>
> for kicks I'll paste in what I have now, although currently all it
> does is intercept prefix'd "\C-c\C-c" commands.
>
> Thanks again
> Eric
>
>
> (defun orgstruct-
> "In Structure, run `org-ctrl-
> check for a prefix argument and if buffer name contains `mail',
> and run orgstruct-
> `\C-c\C-c'."
> (interactive "p")
> (if (org-context-p (quote headline) (quote item))
> (org-run-
> (if (orgstruct-
> (orgstruct-
> (let (orgstruct-mode)
> (call-interactively
> (key-binding "\C-c\C-c"))))))
>
> (defun orgstruct-
> (if (and arg (> arg 1) (string-match "mail" (buffer-name (current-buffer))))
> t))
>
> (defun orgstruct-
> "Export the body of the mail message as html using
> `org-export-
> mail's mime type appropriately, then send"
> ;; use org-export-
> ;; attach to the mail using vm-mime-
> ;; send the mail
> )
>
> --
> schulte
It seems to be working with these functions
if you use orgstruct-mode with or without orgtble-mode load the
following functions, then you can send convert and send html mail with
"\C-u\C-c\C-c"
Cheers,
Eric
(defun orgstruct-
"In Structure, run `org-ctrl-
check for a prefix argument and if buffer name contains `mail',
and run orgstruct-
`\C-c\C-c'."
(interactive "p")
(if (org-context-p (quote headline) (quote item))
(
(if (orgstruct-
(let (orgstruct-mode)
(defun orgstruct-
"lets be pretty sure we have a prefix argument and are actually
in a mail buffer"
(goto-char (point-min))
(if (and arg
(> arg 1)
t))
(defun orgstruct-
"Export the body of the mail message to html using
`org-export-
Content-Type message"
;; adjust mime type
(goto-char (point-min))
(insert "MIME-Version: 1.0\n")
(insert "Content-Type: text/html\n")
(search-forward mail-header-
(let* ((mail-text-point (point))
;; have to write the file because org needs a path to export
(tmp-file (make-temp-name (expand-file-name "org-html-mail" "/tmp")))
(html
(progn
;; convert to html
(switch-
(set-
(delete-file tmp-file)
;; replace text with html
(goto-char mail-text-point)
(delete-region (point) (point-max))
(insert "\n")
(insert html)
;; send the mail
(let (orgstruct-mode)
(
(key-binding "\C-c\C-c")))))
Changed in vm: | |
importance: | Undecided → Wishlist |
Changed in viewmail: | |
importance: | Undecided → Wishlist |
Changed in vm: | |
milestone: | 8.2.0-devo → 8.1.90a |
File org-html-mail.el from Eric Schulte added to the contrib directory.