* compose and send html email using orgmode
@ 2008-01-11 19:44 Eric Schulte
2008-01-15 11:13 ` Carsten Dominik
0 siblings, 1 reply; 4+ messages in thread
From: Eric Schulte @ 2008-01-11 19:44 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 2285 bytes --]
Hi,
Using the attached file it is possible to compose mail using org-mode
(orgstruct, and orgtbl modes to be specific), and then send the mail
as a "text/html" mime message. In effect WYSWYG html email
composition. I find this very useful for sending lists and tables to
co-workers who use non-fixed-width-font email clients.
I put this together with the help of Rob form the gnu.emacs.vm.info
newsgroup, and I use it with VM, but it no-where mentions VM, and it
*should* work with any emacs email composition buffer.
To use place the attached file in your path, and add the following to
you .emacs file
;; org-mode in my mail
(setq mail-turn-on-full-org-mailing-first-time t)
(defun turn-on-full-org-mailing ()
(if mail-turn-on-full-org-mailing-first-time
(progn
(org-publish (car (car org-publish-project-alist)))
(setq mail-turn-on-full-org-mailing-first-time nil)))
;;(turn-on-orgstruct)
(turn-on-orgstruct++)
(turn-on-orgtbl)
(load "org-html-mail.el"))
(add-hook 'mail-mode-hook 'turn-on-full-org-mailing)
Then when composing mail send as an html message by using a prefix
argument on the send command, so "\C-u\C-c\C-c". Your mail will be
converted to html using org's export command, the appropriate mime
headers will be attached, and then your normal send command will be
executed.
Note: This is still very young, so here are some issues, and ideas for
improvement that the list may be able to help with. :)
1. it seems that for the org-export-as-html command to work, the
buffer must be associated with a file, this adds some complexity to
the process, is it possible to export-as-html without associating
the buffer with a path?
2. if org-export-as-html has not yet been called since turning emacs
on, then the following error occurs in org-export-as-html
------*Messages*-------
Exporting... [2 times]
byte-code: Wrong type argument: stringp, nil
------*Messages*-------
Hence they hacky turn-on-full-org-mailing function, and
mail-turn-on-full-org-mailing-first-time variable
3. I would like to add the feature of automatically attaching, and
linking to images from the html, but I haven't really started this,
and I'm not sure how it would work, so any thoughts would be
appreciated.
Thanks,
Eric
[-- Attachment #2: org-html-mail.el --]
[-- Type: text/plain, Size: 3311 bytes --]
;; Eric Schulte
;; 2008-01-10
;;
;; WYSWYG, html mail composition using orgmode
;;
;; For mail composed using the orgstruct-mode minor mode, this
;; provides the option of sending the mail in html format using
;; org-export-as-html.
;;
;; To use place this file in your path, and add the following to you
;; .emacs file
;;
;; ;; org-mode in my mail
;; (setq mail-turn-on-full-org-mailing-first-time t)
;; (defun turn-on-full-org-mailing ()
;; (if mail-turn-on-full-org-mailing-first-time
;; (progn
;; (org-publish (car (car org-publish-project-alist)))
;; (setq mail-turn-on-full-org-mailing-first-time nil)))
;; ;;(turn-on-orgstruct)
;; (turn-on-orgstruct++)
;; (turn-on-orgtbl)
;; (load "org-html-mail.el"))
;; (add-hook 'mail-mode-hook 'turn-on-full-org-mailing)
;;
;; Then when composing mail send as an html message by using a prefix
;; argument on the send command, so "\C-u\C-c\C-c". Your mail will be
;; converted to html using org's export command, the appropriate mime
;; headers will be attached, and then your normal send command will be
;; executed.
;;
(defun orgstruct-hijacker-command-11 (arg)
"In Structure, run `org-ctrl-c-ctrl-c'. Outside of Structure
check for a prefix argument and if buffer name contains `mail',
and run orgstruct-send-as-html, or run the binding of
`\C-c\C-c'."
(interactive "p")
(if (org-context-p (quote headline) (quote item))
(org-run-like-in-org-mode (quote org-ctrl-c-ctrl-c))
(if (orgstruct-send-as-html-should-i-p arg)
(orgstruct-send-as-html)
(let (orgstruct-mode)
(call-interactively
(key-binding "\C-c\C-c"))))))
(defun orgstruct-send-as-html-should-i-p (arg)
"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)
(string-match "mail" (buffer-name (current-buffer)))
(search-forward mail-header-separator))
t))
;; TODO something needs to load when org exports to html, it works
;; when I have already exported an org file, but not if I haven't
;; since turning on emacs
(defun orgstruct-send-as-html ()
"Export the body of the mail message to html using
`org-export-as-html' then send the results as a text/html
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-separator)
(let* ((mail-text-point (point))
(mail-buffer (current-buffer))
;; have to write the file because org needs a path to export
(tmp-file (make-temp-name (expand-file-name "schulte" "/tmp/")))
;; because we probably don't want to skip part of our mail
(org-export-skip-text-before-1st-heading nil)
(html
(progn
(write-file tmp-file)
;; convert to html
(org-export-region-as-html mail-text-point (point-max) t 'string))))
(switch-to-buffer mail-buffer)
(set-visited-file-name nil)
(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)
(call-interactively
(key-binding "\C-c\C-c")))))
[-- Attachment #3: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compose and send html email using orgmode
2008-01-11 19:44 compose and send html email using orgmode Eric Schulte
@ 2008-01-15 11:13 ` Carsten Dominik
2008-01-15 21:36 ` Eric Schulte
0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2008-01-15 11:13 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
Hi Eric,
this is a *very* interesting application.
On Jan 11, 2008, at 8:44 PM, Eric Schulte wrote:
>
> Note: This is still very young, so here are some issues, and ideas for
> improvement that the list may be able to help with. :)
>
> 1. it seems that for the org-export-as-html command to work, the
> buffer must be associated with a file, this adds some complexity to
> the process, is it possible to export-as-html without associating
> the buffer with a path?
You can use org-replace-region-by-html which will work in a buffer
without a file.
>
> 2. if org-export-as-html has not yet been called since turning emacs
> on, then the following error occurs in org-export-as-html
> ------*Messages*-------
> Exporting... [2 times]
> byte-code: Wrong type argument: stringp, nil
> ------*Messages*-------
> Hence they hacky turn-on-full-org-mailing function, and
> mail-turn-on-full-org-mailing-first-time variable
Can you provide more details about how to produce this bug?
- Carsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compose and send html email using orgmode
2008-01-15 11:13 ` Carsten Dominik
@ 2008-01-15 21:36 ` Eric Schulte
2008-01-16 8:06 ` Carsten Dominik
0 siblings, 1 reply; 4+ messages in thread
From: Eric Schulte @ 2008-01-15 21:36 UTC (permalink / raw)
To: Carsten Dominik; +Cc: emacs-orgmode
Hi, Carsten
Thanks for looking into this.
On Tuesday, January 15, at 12:13, Carsten Dominik wrote:
> Hi Eric,
>
> this is a *very* interesting application.
>
> On Jan 11, 2008, at 8:44 PM, Eric Schulte wrote:
> >
> > Note: This is still very young, so here are some issues, and ideas for
> > improvement that the list may be able to help with. :)
> >
> > 1. it seems that for the org-export-as-html command to work, the
> > buffer must be associated with a file, this adds some complexity to
> > the process, is it possible to export-as-html without associating
> > the buffer with a path?
>
> You can use org-replace-region-by-html which will work in a buffer
> without a file.
Thanks, I will try that out, which should help to greatly trim down
the amount/complexity of this code.
> >
> > 2. if org-export-as-html has not yet been called since turning emacs
> > on, then the following error occurs in org-export-as-html
> > ------*Messages*-------
> > Exporting... [2 times]
> > byte-code: Wrong type argument: stringp, nil
> > ------*Messages*-------
> > Hence they hacky turn-on-full-org-mailing function, and
> > mail-turn-on-full-org-mailing-first-time variable
>
> Can you provide more details about how to produce this bug?
yes, the simplest way to reproduce is...
1. completely turn off emacs
2. start up emacs
3. open a non-org-mode buffer (I began editing a file called "test")
4. start up orgstruct-mode
5. enter some text, select the text as a region, then call
org-export-region-as-html
this function should fail with something like this in your messages.
Exporting... [2 times]
Wrong type argument: stringp, nil
I'm using GNU Emacs 22, with org-5.17a
Hope this helps,
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compose and send html email using orgmode
2008-01-15 21:36 ` Eric Schulte
@ 2008-01-16 8:06 ` Carsten Dominik
0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2008-01-16 8:06 UTC (permalink / raw)
To: schulte.eric; +Cc: emacs-orgmode
>
> yes, the simplest way to reproduce is...
>
> 1. completely turn off emacs
> 2. start up emacs
> 3. open a non-org-mode buffer (I began editing a file called "test")
> 4. start up orgstruct-mode
> 5. enter some text, select the text as a region, then call
> org-export-region-as-html
>
> this function should fail with something like this in your messages.
>
> Exporting... [2 times]
> Wrong type argument: stringp, nil
Ah, of course, since this is not an org-mode buffer, all
the local variables needed by org-mode functions are not
initialized. You need to call the function like this:
(org-run-like-in-org-mode 'org-export-region-as-html)
- Carsten
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-16 8:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-11 19:44 compose and send html email using orgmode Eric Schulte
2008-01-15 11:13 ` Carsten Dominik
2008-01-15 21:36 ` Eric Schulte
2008-01-16 8:06 ` Carsten Dominik
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.