emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* using orgmode to send html mail?
@ 2010-03-22  2:34 Matt Price
  2010-03-22 15:44 ` Matt Price
  2010-03-22 20:18 ` David Maus
  0 siblings, 2 replies; 63+ messages in thread
From: Matt Price @ 2010-03-22  2:34 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I just wondered whether anyone composes mail in orgmode & then
generates html from the source code.  I'd like to be able to do that
sometimes in wanderlust, e.g. when I'm responding to html mail with
links in it.

like I say, just wondering -- glad for any help anyone can offe.r  thanks,
matt

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-22  2:34 using orgmode to send html mail? Matt Price
@ 2010-03-22 15:44 ` Matt Price
  2010-03-22 20:18 ` David Maus
  1 sibling, 0 replies; 63+ messages in thread
From: Matt Price @ 2010-03-22 15:44 UTC (permalink / raw)
  To: emacs-orgmode

On Sun, Mar 21, 2010 at 10:34 PM, Matt Price <moptop99@gmail.com> wrote:
> Hi,
>
> I just wondered whether anyone composes mail in orgmode & then
> generates html from the source code.  I'd like to be able to do that
> sometimes in wanderlust, e.g. when I'm responding to html mail with
> links in it.
>
found the following in the middle of a thread from the emacs-vm newsgroup:

http://groups.google.com/group/gnu.emacs.vm.info/attach/2cf9c04b3607df35/org-html-mail.el?part=2

see also
http://www.mail-archive.com/emacs-orgmode@gnu.org/msg05045.html

does anyone on the list still use this code?  I'm not finding that it
works for me, either with wancerlust or just straight M-x mail, and
since all these functionalities are fairly ocmplex I[m not really sure
where to begin to look for answers.  Thanks so much in advance, best,
Matt

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-22  2:34 using orgmode to send html mail? Matt Price
  2010-03-22 15:44 ` Matt Price
@ 2010-03-22 20:18 ` David Maus
  2010-03-23 19:54   ` Eric Schulte
  1 sibling, 1 reply; 63+ messages in thread
From: David Maus @ 2010-03-22 20:18 UTC (permalink / raw)
  To: Matt Price; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 7511 bytes --]

Matt Price wrote:
>Hi,

>I just wondered whether anyone composes mail in orgmode & then
>generates html from the source code.  I'd like to be able to do that
>sometimes in wanderlust, e.g. when I'm responding to html mail with
>links in it.

Just pushed to hacks to Worg on how to send html messages in
Wanderlust using Org's html exporter and how to attach html markup of
a region or subtree in Wanderlust.  Latter is a follow-up on

http://lists.gnu.org/archive/html/emacs-orgmode/2009-11/msg00746.html

Until Worg picks it up:

1 Send html messages and attachments with Wanderlust
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  -- David Maus

These two hacks below add the capability of using Org to send out html
via email.  Both focus on Wanderlust but could be easily adopted for
Gnus, I think.

1.1 Send HTML message
======================

Putting the code below in your .emacs adds following four functions:

   - dmj/wl-send-html-message

     Function that does the job: Convert everything between "--text
     follows this line--" and first mime entity (read: attachment) or
     end of buffer into HTML markup using `org-export-region-as-html'
     and replaces original body with a mime entity of text/html,
     content-disposition: inline.  Line breaks of the signature are
     preserved.

     Cannot be called interactively: It is hooked into SEMI's
     `mime-edit-translate-hook' if message should be HTML message.

   - dmj/wl-send-html-message-draft-init

     Cannot be called interactively: It is hooked into WL's
     `wl-mail-setup-hook' and `wl-draft-reedit-hook' and provides a
     buffer local variable to toggle.

   - dmj/wl-send-html-message-draft-maybe

     Cannot be called interactively: It is hooked into WL's
     `wl-draft-send-hook' and hooks `dmj/wl-send-html-message' into
     `mime-edit-translate-hook' depending on whether HTML message is
     toggled on or off

   - dmj/wl-send-html-message-toggle

     Toggles sending of HTML message.  If toggled on, the letters
     "HTML" appear in the mode line.

     Call it interactively!  Or bind it to a key in `wl-draft-mode'.

If you have to send HTML messages regularly you can set a global
variable `dmj/wl-send-html-message-toggled-p' to the string "HTML" to
toggle on sending HTML message by default.

The image [here] shows an example of how the HTML message looks like in
Google's web front end.  As you can see you have the whole markup of
Org at your service: *bold*, /italics/, tables, lists...

So even if you feel uncomfortable with sending HTML messages at least
you send HTML that looks quite good.


  (defun dmj/wl-send-html-message ()
    "Send message as html message.
    Convert body of message to html using
    `org-export-region-as-html'."
    (require 'org)
    (save-excursion
      (let (beg end html text)
        (goto-char (point-min))
        (re-search-forward "^--text follows this line--$")
        ;; move to beginning of next line
        (beginning-of-line 2)
        (setq beg (point))
        (if (not (re-search-forward "^--\\[\\[" nil t))
            (setq end (point-max))
          ;; line up
          (end-of-line 0)
          (setq end (point)))
        ;; grab body
        (setq text (buffer-substring-no-properties beg end))
        ;; convert to html
        (with-temp-buffer
          (org-mode)
          (insert text)
          ;; handle signature
          (when (re-search-backward "^-- \n" nil t)
            ;; preserve link breaks in signature
            (insert "\n#+BEGIN_VERSE\n")
            (goto-char (point-max))
            (insert "\n#+END_VERSE\n")
            ;; grab html
            (setq html (org-export-region-as-html
                        (point-min) (point-max) t 'string))))
        (delete-region beg end)
        (insert
         (concat
          "--[text/html\nContent-Disposition: inline]\n"
          html)))))

  (defun dmj/wl-send-html-message-toggle ()
    "Toggle sending of html message."
    (interactive)
    (setq dmj/wl-send-html-message-toggled-p
          (if dmj/wl-send-html-message-toggled-p
              nil "HTML"))
    (message "Sending html message toggled %s"
             (if dmj/wl-send-html-message-toggled-p
                 "on" "off")))

    (defun dmj/wl-send-html-message-draft-init ()
      "Create buffer local settings for maybe sending html message."
      (unless (boundp 'dmj/wl-send-html-message-toggled-p)
        (setq dmj/wl-send-html-message-toggled-p nil))
      (make-variable-buffer-local 'dmj/wl-send-html-message-toggled-p)
      (add-to-list 'global-mode-string
                   '(:eval (if (eq major-mode 'wl-draft-mode)
                               dmj/wl-send-html-message-toggled-p))))

    (defun dmj/wl-send-html-message-maybe ()
      "Maybe send this message as html message.

    If buffer local variable `dmj/wl-send-html-message-toggled-p' is
    non-nil, add `dmj/wl-send-html-message' to
    `mime-edit-translate-hook'."
      (if dmj/wl-send-html-message-toggled-p
          (add-hook 'mime-edit-translate-hook 'dmj/wl-send-html-message)
        (remove-hook 'mime-edit-translate-hook 'dmj/wl-send-html-message)))

  (add-hook 'wl-draft-reedit-hook 'dmj/wl-send-html-message-draft-init)
  (add-hook 'wl-mail-setup-hook 'dmj/wl-send-html-message-draft-init)
  (add-hook 'wl-draft-send-hook 'dmj/wl-send-html-message-maybe)



  [here]: http://s11.directupload.net/file/u/15851/48ru5wl3.png

1.2 Attach HTML of region or subtree
=====================================

Instead of sending a complete HTML message you might only send parts
of an Org file as HTML for the poor souls who are plagued with
non-proportional fonts in their mail program that messes up pretty
ASCII tables.

This short function does the trick: It exports region or subtree to
HTML, prefixes it with a MIME entity delimiter and pushes to killring
and clipboard.  If a region is active, it uses the region, the
complete subtree otherwise.


  (defun dmj/org-export-region-as-html-attachment (beg end arg)
    "Export region between BEG and END as html attachment.
  If BEG and END are not set, use current subtree.  Region or
  subtree is exported to html without header and footer, prefixed
  with a mime entity string and pushed to clipboard and killring.
  When called with prefix, mime entity is not marked as
  attachment."
    (interactive "r\nP")
    (save-excursion
      (let* ((beg (if (region-active-p) (region-beginning)
                    (progn
                      (org-back-to-heading)
                      (point))))
             (end (if (region-active-p) (region-end)
                    (progn
                      (org-end-of-subtree)
                      (point))))
             (html (concat "--" "[[text/html"
                           (if arg "" "\nContent-Disposition: attachment")
                           "]]\n"
                           (org-export-region-as-html beg end t 'string))))
        (when (fboundp 'x-set-selection)
          (ignore-errors (x-set-selection 'PRIMARY html))
          (ignore-errors (x-set-selection 'CLIPBOARD html)))
        (message "html export done, pushed to kill ring and clipboard"))))

1.3 Adopting for Gnus
======================

The whole magic lies in the special strings that mark a HTML
attachment.  So you might just have to find out what these special
strings are in message-mode and modify the functions accordingly.
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-22 20:18 ` David Maus
@ 2010-03-23 19:54   ` Eric Schulte
  2010-03-23 21:46     ` Xiao-Yong Jin
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-03-23 19:54 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

Nice to see this topic has come back to life.

I've been playing with my old org-html-mail.el file, and come up with a
much simpler solution, which takes advantage of the mml message mode
functionality with is used in gnus (and I would imagine in some other
Emacs mail clients, but I can't be sure).

Just call this function and either the active region of your message
buffer or the entire body (if no region is active) will be exported to
html using org-mode, and will be wrapped in the appropriate mml wrapper
to be sent as the appropriate mime type.

So for example this
|            1 |      2 |     3 |
|--------------+--------+-------|
| first column | second | third |

will be exported as this

[-- Attachment #2.1: Type: text/html, Size: 364 bytes --]

[-- Attachment #3: Type: text/plain, Size: 49 bytes --]


The function is provided in the attached file.


[-- Attachment #4: org-mml-htmlize.el --]
[-- Type: application/emacs-lisp, Size: 1871 bytes --]

[-- Attachment #5: Type: text/plain, Size: 8128 bytes --]


Best -- Eric

David Maus <dmaus@ictsoc.de> writes:

> Matt Price wrote:
>>Hi,
>
>>I just wondered whether anyone composes mail in orgmode & then
>>generates html from the source code.  I'd like to be able to do that
>>sometimes in wanderlust, e.g. when I'm responding to html mail with
>>links in it.
>
> Just pushed to hacks to Worg on how to send html messages in
> Wanderlust using Org's html exporter and how to attach html markup of
> a region or subtree in Wanderlust.  Latter is a follow-up on
>
> http://lists.gnu.org/archive/html/emacs-orgmode/2009-11/msg00746.html
>
> Until Worg picks it up:
>
> 1 Send html messages and attachments with Wanderlust
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   -- David Maus
>
> These two hacks below add the capability of using Org to send out html
> via email.  Both focus on Wanderlust but could be easily adopted for
> Gnus, I think.
>
> 1.1 Send HTML message
> ======================
>
> Putting the code below in your .emacs adds following four functions:
>
>    - dmj/wl-send-html-message
>
>      Function that does the job: Convert everything between "--text
>      follows this line--" and first mime entity (read: attachment) or
>      end of buffer into HTML markup using `org-export-region-as-html'
>      and replaces original body with a mime entity of text/html,
>      content-disposition: inline.  Line breaks of the signature are
>      preserved.
>
>      Cannot be called interactively: It is hooked into SEMI's
>      `mime-edit-translate-hook' if message should be HTML message.
>
>    - dmj/wl-send-html-message-draft-init
>
>      Cannot be called interactively: It is hooked into WL's
>      `wl-mail-setup-hook' and `wl-draft-reedit-hook' and provides a
>      buffer local variable to toggle.
>
>    - dmj/wl-send-html-message-draft-maybe
>
>      Cannot be called interactively: It is hooked into WL's
>      `wl-draft-send-hook' and hooks `dmj/wl-send-html-message' into
>      `mime-edit-translate-hook' depending on whether HTML message is
>      toggled on or off
>
>    - dmj/wl-send-html-message-toggle
>
>      Toggles sending of HTML message.  If toggled on, the letters
>      "HTML" appear in the mode line.
>
>      Call it interactively!  Or bind it to a key in `wl-draft-mode'.
>
> If you have to send HTML messages regularly you can set a global
> variable `dmj/wl-send-html-message-toggled-p' to the string "HTML" to
> toggle on sending HTML message by default.
>
> The image [here] shows an example of how the HTML message looks like in
> Google's web front end.  As you can see you have the whole markup of
> Org at your service: *bold*, /italics/, tables, lists...
>
> So even if you feel uncomfortable with sending HTML messages at least
> you send HTML that looks quite good.
>
>
>   (defun dmj/wl-send-html-message ()
>     "Send message as html message.
>     Convert body of message to html using
>     `org-export-region-as-html'."
>     (require 'org)
>     (save-excursion
>       (let (beg end html text)
>         (goto-char (point-min))
>         (re-search-forward "^--text follows this line--$")
>         ;; move to beginning of next line
>         (beginning-of-line 2)
>         (setq beg (point))
>         (if (not (re-search-forward "^--\\[\\[" nil t))
>             (setq end (point-max))
>           ;; line up
>           (end-of-line 0)
>           (setq end (point)))
>         ;; grab body
>         (setq text (buffer-substring-no-properties beg end))
>         ;; convert to html
>         (with-temp-buffer
>           (org-mode)
>           (insert text)
>           ;; handle signature
>           (when (re-search-backward "^-- \n" nil t)
>             ;; preserve link breaks in signature
>             (insert "\n#+BEGIN_VERSE\n")
>             (goto-char (point-max))
>             (insert "\n#+END_VERSE\n")
>             ;; grab html
>             (setq html (org-export-region-as-html
>                         (point-min) (point-max) t 'string))))
>         (delete-region beg end)
>         (insert
>          (concat
>           "--[text/html\nContent-Disposition: inline]\n"
>           html)))))
>
>   (defun dmj/wl-send-html-message-toggle ()
>     "Toggle sending of html message."
>     (interactive)
>     (setq dmj/wl-send-html-message-toggled-p
>           (if dmj/wl-send-html-message-toggled-p
>               nil "HTML"))
>     (message "Sending html message toggled %s"
>              (if dmj/wl-send-html-message-toggled-p
>                  "on" "off")))
>
>     (defun dmj/wl-send-html-message-draft-init ()
>       "Create buffer local settings for maybe sending html message."
>       (unless (boundp 'dmj/wl-send-html-message-toggled-p)
>         (setq dmj/wl-send-html-message-toggled-p nil))
>       (make-variable-buffer-local 'dmj/wl-send-html-message-toggled-p)
>       (add-to-list 'global-mode-string
>                    '(:eval (if (eq major-mode 'wl-draft-mode)
>                                dmj/wl-send-html-message-toggled-p))))
>
>     (defun dmj/wl-send-html-message-maybe ()
>       "Maybe send this message as html message.
>
>     If buffer local variable `dmj/wl-send-html-message-toggled-p' is
>     non-nil, add `dmj/wl-send-html-message' to
>     `mime-edit-translate-hook'."
>       (if dmj/wl-send-html-message-toggled-p
>           (add-hook 'mime-edit-translate-hook 'dmj/wl-send-html-message)
>         (remove-hook 'mime-edit-translate-hook 'dmj/wl-send-html-message)))
>
>   (add-hook 'wl-draft-reedit-hook 'dmj/wl-send-html-message-draft-init)
>   (add-hook 'wl-mail-setup-hook 'dmj/wl-send-html-message-draft-init)
>   (add-hook 'wl-draft-send-hook 'dmj/wl-send-html-message-maybe)
>
>
>
>   [here]: http://s11.directupload.net/file/u/15851/48ru5wl3.png
>
> 1.2 Attach HTML of region or subtree
> =====================================
>
> Instead of sending a complete HTML message you might only send parts
> of an Org file as HTML for the poor souls who are plagued with
> non-proportional fonts in their mail program that messes up pretty
> ASCII tables.
>
> This short function does the trick: It exports region or subtree to
> HTML, prefixes it with a MIME entity delimiter and pushes to killring
> and clipboard.  If a region is active, it uses the region, the
> complete subtree otherwise.
>
>
>   (defun dmj/org-export-region-as-html-attachment (beg end arg)
>     "Export region between BEG and END as html attachment.
>   If BEG and END are not set, use current subtree.  Region or
>   subtree is exported to html without header and footer, prefixed
>   with a mime entity string and pushed to clipboard and killring.
>   When called with prefix, mime entity is not marked as
>   attachment."
>     (interactive "r\nP")
>     (save-excursion
>       (let* ((beg (if (region-active-p) (region-beginning)
>                     (progn
>                       (org-back-to-heading)
>                       (point))))
>              (end (if (region-active-p) (region-end)
>                     (progn
>                       (org-end-of-subtree)
>                       (point))))
>              (html (concat "--" "[[text/html"
>                            (if arg "" "\nContent-Disposition: attachment")
>                            "]]\n"
>                            (org-export-region-as-html beg end t 'string))))
>         (when (fboundp 'x-set-selection)
>           (ignore-errors (x-set-selection 'PRIMARY html))
>           (ignore-errors (x-set-selection 'CLIPBOARD html)))
>         (message "html export done, pushed to kill ring and clipboard"))))
>
> 1.3 Adopting for Gnus
> ======================
>
> The whole magic lies in the special strings that mark a HTML
> attachment.  So you might just have to find out what these special
> strings are in message-mode and modify the functions accordingly.
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

[-- Attachment #6: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-23 19:54   ` Eric Schulte
@ 2010-03-23 21:46     ` Xiao-Yong Jin
  2010-03-24 15:00       ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Xiao-Yong Jin @ 2010-03-23 21:46 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

On Tue, 23 Mar 2010 13:54:39 -0600, Eric Schulte wrote:

> Nice to see this topic has come back to life.
> I've been playing with my old org-html-mail.el file, and come up with a
> much simpler solution, which takes advantage of the mml message mode
> functionality with is used in gnus (and I would imagine in some other
> Emacs mail clients, but I can't be sure).

> Just call this function and either the active region of your message
> buffer or the entire body (if no region is active) will be exported to
> html using org-mode, and will be wrapped in the appropriate mml wrapper
> to be sent as the appropriate mime type.

Thumbs up for this one.  It should be included in
org-contrib, probably after taken care of other mail client
in emacs?

> So for example this
>> 1 |      2 |     3 |
>> --------------+--------+-------|
>> first column | second | third |

> will be exported as this
> ━━━━━━━━━━━━━━
>        1          2       3   
> ──────────────
>  first column   second  third 
> ━━━━━━━━━━━━━━

I use emacs-w3m in gnus, and the table looks great.
-- 
J    c/*    __o/*
X    <\     * (__
Y    */\      <

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-23 21:46     ` Xiao-Yong Jin
@ 2010-03-24 15:00       ` Eric Schulte
  2010-03-24 17:50         ` Dan Davison
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-03-24 15:00 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 924 bytes --]

Xiao-Yong Jin <xj2106@columbia.edu> writes:

> On Tue, 23 Mar 2010 13:54:39 -0600, Eric Schulte wrote:
>
>> Nice to see this topic has come back to life.
>> I've been playing with my old org-html-mail.el file, and come up with a
>> much simpler solution, which takes advantage of the mml message mode
>> functionality with is used in gnus (and I would imagine in some other
>> Emacs mail clients, but I can't be sure).
>
>> Just call this function and either the active region of your message
>> buffer or the entire body (if no region is active) will be exported to
>> html using org-mode, and will be wrapped in the appropriate mml wrapper
>> to be sent as the appropriate mime type.
>

I've cleaned up the function somewhat, I'll include it immediately
below by inserting it in a org-mode src_block and then exporting it to
html, so those with html mail readers should see a nicely fontified
version of the source code.


[-- Attachment #2.1: Type: text/html, Size: 5397 bytes --]

[-- Attachment #3: Type: text/plain, Size: 1037 bytes --]


>
> Thumbs up for this one.  It should be included in
> org-contrib, probably after taken care of other mail client
> in emacs?
>

I have looked somewhat at both VM and Wanderlust, but they appear to use
their own mime encoding schemes other than mml, so this won't work as-is
in those mail clients.  That said, assuming they also use simple mime
encoding strings it should be hard to replace the mml specific mime
delimiters presented as strings in the above functions with string
delimiters appropriate for the other mail agents.

also, I have to say I feel bad about publishing code which promotes the
use of HTML mail.  Generally I feel that everyone would be better off if
they just used fixed width text email clients.  As a concession to that
intuition, if this function is called with a prefix argument, it will
wrap the region (or entire email) as html in <pre></pre> tags ensuring
that it will be rendered in a fixed-with font no-matter the receivers
email client, so the following table should actually look like a
table...


[-- Attachment #4.1: Type: text/html, Size: 264 bytes --]

[-- Attachment #5: Type: text/plain, Size: 447 bytes --]


Best -- Eric

>
>> So for example this
>>> 1 |      2 |     3 |
>>> --------------+--------+-------|
>>> first column | second | third |
>
>> will be exported as this
>> ━━━━━━━━━━━━━━
>>        1          2       3   
>> ──────────────
>>  first column   second  third 
>> ━━━━━━━━━━━━━━
>
> I use emacs-w3m in gnus, and the table looks great.

[-- Attachment #6: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-24 15:00       ` Eric Schulte
@ 2010-03-24 17:50         ` Dan Davison
  2010-03-24 18:01           ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Dan Davison @ 2010-03-24 17:50 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Xiao-Yong Jin <xj2106@columbia.edu> writes:
>
>> On Tue, 23 Mar 2010 13:54:39 -0600, Eric Schulte wrote:
>>
>>> Nice to see this topic has come back to life.
>>> I've been playing with my old org-html-mail.el file, and come up with a
>>> much simpler solution, which takes advantage of the mml message mode
>>> functionality with is used in gnus (and I would imagine in some other
>>> Emacs mail clients, but I can't be sure).
>>
>>> Just call this function and either the active region of your message
>>> buffer or the entire body (if no region is active) will be exported to
>>> html using org-mode, and will be wrapped in the appropriate mml wrapper
>>> to be sent as the appropriate mime type.
>>
>
> I've cleaned up the function somewhat, I'll include it immediately
> below by inserting it in a org-mode src_block and then exporting it to
> html, so those with html mail readers should see a nicely fontified
> version of the source code.

This is really nice. I already sent my first HTML-formatted tables to
colleagues with it yesterday. And yes, the email comes up with nicely
formatted elisp in my web browser after hitting 'K H' in gnus.

Dan

>
> (defun org-mml-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."
>   (interactive "P")
>   (let* ((region-p (org-region-active-p))
>          (html-start (or (and region-p (region-beginning))
>                          (save-excursion
>                            (goto-char (point-min))
>                            (search-forward mail-header-separator)
>                            (point))))
>          (html-end (or (and region-p (region-end))
>                        ;; TODO: should catch signature...
>                        (point-max)))
>          (body (buffer-substring html-start html-end))
>          (tmp-file (make-temp-name (expand-file-name "mail" "/tmp/")))
>          ;; because we probably don't want to skip part of our mail
>          (org-export-skip-text-before-1st-heading nil)
>          ;; because we probably don't want to export a huge style file
>          (org-export-htmlize-output-type 'inline-css)
>          ;; makes the replies with ">"s look nicer
>          (org-export-preserve-breaks t)
>          (html (if arg
>                    (format "<pre style=\"font-family: courier, monospace;\">\n%s</pre>\n" body)
>                  (save-excursion
>                    (with-temp-buffer
>                      (insert body)
>                      (write-file tmp-file)
>                      ;; convert to html -- mimicing `org-run-like-in-org-mode'
>                      (eval (list 'let org-local-vars
>                                  (list 'org-export-as-html nil nil nil ''string t))))))))
>     (delete-region html-start html-end)
>     (save-excursion
>       (goto-char html-start)
>       (insert
>        (format
>         "\n<#multipart type=alternative>\n<#part type=text/html>%s<#/multipart>\n"
>         html)))))
>
>
>>
>> Thumbs up for this one.  It should be included in
>> org-contrib, probably after taken care of other mail client
>> in emacs?
>>
>
> I have looked somewhat at both VM and Wanderlust, but they appear to use
> their own mime encoding schemes other than mml, so this won't work as-is
> in those mail clients.  That said, assuming they also use simple mime
> encoding strings it should be hard to replace the mml specific mime
> delimiters presented as strings in the above functions with string
> delimiters appropriate for the other mail agents.
>
> also, I have to say I feel bad about publishing code which promotes the
> use of HTML mail.  Generally I feel that everyone would be better off if
> they just used fixed width text email clients.  As a concession to that
> intuition, if this function is called with a prefix argument, it will
> wrap the region (or entire email) as html in <pre></pre> tags ensuring
> that it will be rendered in a fixed-with font no-matter the receivers
> email client, so the following table should actually look like a
> table...
>
> | this table   |   | n | fibb(n) |
> |--------------+---+---+---------|
> | is           |   | 0 |       0 |
> | inside       |   | 1 |       1 |
> | of a pre box |   | 2 |       1 |
> |              |   | 3 |       2 |
>
>
> Best -- Eric
>
>>
>>> So for example this
>>>> 1 |      2 |     3 |
>>>> --------------+--------+-------|
>>>> first column | second | third |
>>
>>> will be exported as this
>>> ━━━━━━━━━━━━━━
>>>        1          2       3   
>>> ──────────────
>>>  first column   second  third 
>>> ━━━━━━━━━━━━━━
>>
>> I use emacs-w3m in gnus, and the table looks great.
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-24 17:50         ` Dan Davison
@ 2010-03-24 18:01           ` Eric Schulte
  2010-03-24 19:12             ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-03-24 18:01 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Thanks Dan,

I'm happy to hear I'm not the only person who's enjoying playing with
this :).

Aside from changing the mime-delimeters for VM and wanderlust, it seems
to me that the only remaining step between the current functionality and
a seamless use of org-mode for email composition, is the resolution of
images as email attachments.  That would allow emails with embedded
latex (which I personally would find very compelling), as well as
embedded ditaa diagrams and images.  If anyone knows more about mime,
I'd be interested to hear suggestions, but I may try a first pass using
`replace-regexp' to replace all <img> links with inline mime image
attachments.

I've just made a couple of small changes, and pushed this file up to a
git repo at http://github.com/eschulte/org-html-mail, or for raw elisp
http://github.com/eschulte/org-html-mail/raw/master/org-mml-htmlize.el

Cheers -- Eric

Dan Davison <davison@stats.ox.ac.uk> writes:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Xiao-Yong Jin <xj2106@columbia.edu> writes:
>>
>>> On Tue, 23 Mar 2010 13:54:39 -0600, Eric Schulte wrote:
>>>
>>>> Nice to see this topic has come back to life.
>>>> I've been playing with my old org-html-mail.el file, and come up with a
>>>> much simpler solution, which takes advantage of the mml message mode
>>>> functionality with is used in gnus (and I would imagine in some other
>>>> Emacs mail clients, but I can't be sure).
>>>
>>>> Just call this function and either the active region of your message
>>>> buffer or the entire body (if no region is active) will be exported to
>>>> html using org-mode, and will be wrapped in the appropriate mml wrapper
>>>> to be sent as the appropriate mime type.
>>>
>>
>> I've cleaned up the function somewhat, I'll include it immediately
>> below by inserting it in a org-mode src_block and then exporting it to
>> html, so those with html mail readers should see a nicely fontified
>> version of the source code.
>
> This is really nice. I already sent my first HTML-formatted tables to
> colleagues with it yesterday. And yes, the email comes up with nicely
> formatted elisp in my web browser after hitting 'K H' in gnus.
>
> Dan
>
>>
>> (defun org-mml-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."
>>   (interactive "P")
>>   (let* ((region-p (org-region-active-p))
>>          (html-start (or (and region-p (region-beginning))
>>                          (save-excursion
>>                            (goto-char (point-min))
>>                            (search-forward mail-header-separator)
>>                            (point))))
>>          (html-end (or (and region-p (region-end))
>>                        ;; TODO: should catch signature...
>>                        (point-max)))
>>          (body (buffer-substring html-start html-end))
>>          (tmp-file (make-temp-name (expand-file-name "mail" "/tmp/")))
>>          ;; because we probably don't want to skip part of our mail
>>          (org-export-skip-text-before-1st-heading nil)
>>          ;; because we probably don't want to export a huge style file
>>          (org-export-htmlize-output-type 'inline-css)
>>          ;; makes the replies with ">"s look nicer
>>          (org-export-preserve-breaks t)
>>          (html (if arg
>>                    (format "<pre style=\"font-family: courier, monospace;\">\n%s</pre>\n" body)
>>                  (save-excursion
>>                    (with-temp-buffer
>>                      (insert body)
>>                      (write-file tmp-file)
>>                      ;; convert to html -- mimicing `org-run-like-in-org-mode'
>>                      (eval (list 'let org-local-vars
>>                                  (list 'org-export-as-html nil nil nil ''string t))))))))
>>     (delete-region html-start html-end)
>>     (save-excursion
>>       (goto-char html-start)
>>       (insert
>>        (format
>>         "\n<#multipart type=alternative>\n<#part type=text/html>%s<#/multipart>\n"
>>         html)))))
>>
>>
>>>
>>> Thumbs up for this one.  It should be included in
>>> org-contrib, probably after taken care of other mail client
>>> in emacs?
>>>
>>
>> I have looked somewhat at both VM and Wanderlust, but they appear to use
>> their own mime encoding schemes other than mml, so this won't work as-is
>> in those mail clients.  That said, assuming they also use simple mime
>> encoding strings it should be hard to replace the mml specific mime
>> delimiters presented as strings in the above functions with string
>> delimiters appropriate for the other mail agents.
>>
>> also, I have to say I feel bad about publishing code which promotes the
>> use of HTML mail.  Generally I feel that everyone would be better off if
>> they just used fixed width text email clients.  As a concession to that
>> intuition, if this function is called with a prefix argument, it will
>> wrap the region (or entire email) as html in <pre></pre> tags ensuring
>> that it will be rendered in a fixed-with font no-matter the receivers
>> email client, so the following table should actually look like a
>> table...
>>
>> | this table   |   | n | fibb(n) |
>> |--------------+---+---+---------|
>> | is           |   | 0 |       0 |
>> | inside       |   | 1 |       1 |
>> | of a pre box |   | 2 |       1 |
>> |              |   | 3 |       2 |
>>
>>
>> Best -- Eric
>>
>>>
>>>> So for example this
>>>>> 1 |      2 |     3 |
>>>>> --------------+--------+-------|
>>>>> first column | second | third |
>>>
>>>> will be exported as this
>>>> ━━━━━━━━━━━━━━
>>>>        1          2       3   
>>>> ──────────────
>>>>  first column   second  third 
>>>> ━━━━━━━━━━━━━━
>>>
>>> I use emacs-w3m in gnus, and the table looks great.
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-24 18:01           ` Eric Schulte
@ 2010-03-24 19:12             ` David Maus
  2010-03-24 20:19               ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-03-24 19:12 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1627 bytes --]

Eric Schulte wrote:
>Thanks Dan,

>I'm happy to hear I'm not the only person who's enjoying playing with
>this :).

>Aside from changing the mime-delimeters for VM and wanderlust, it seems
>to me that the only remaining step between the current functionality and
>a seamless use of org-mode for email composition, is the resolution of
>images as email attachments.  That would allow emails with embedded
>latex (which I personally would find very compelling), as well as
>embedded ditaa diagrams and images.  If anyone knows more about mime,
>I'd be interested to hear suggestions, but I may try a first pass using
>`replace-regexp' to replace all <img> links with inline mime image
>attachments.

Taking a look into the MIME specs (RFC2045ff) regarding this issue is
on my list.  My biggest concern with utilizing more MIME capabilities
is, that you have little control over what the recipient's MUA will do.

Don't know about VM, but with regards to WL I'd imagine something
like:

 - first represent the MIME strukture in a list

 - then call translating functions that insert the appropriate
   delimeters

>I've just made a couple of small changes, and pushed this file up to a
>git repo at http://github.com/eschulte/org-html-mail, or for raw elisp
>http://github.com/eschulte/org-html-mail/raw/master/org-mml-htmlize.el

Just out of curiosity: Why do you write to a temp file and not just
insert the body in a temporary buffer, turn on org-mode and use
org-export-region-as-html (point-min) (point-max) nil t 'string)?

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-24 19:12             ` David Maus
@ 2010-03-24 20:19               ` Eric Schulte
  2010-03-25 21:17                 ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-03-24 20:19 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

> Eric Schulte wrote:
>>Thanks Dan,
>
>>I'm happy to hear I'm not the only person who's enjoying playing with
>>this :).
>
>>Aside from changing the mime-delimeters for VM and wanderlust, it seems
>>to me that the only remaining step between the current functionality and
>>a seamless use of org-mode for email composition, is the resolution of
>>images as email attachments.  That would allow emails with embedded
>>latex (which I personally would find very compelling), as well as
>>embedded ditaa diagrams and images.  If anyone knows more about mime,
>>I'd be interested to hear suggestions, but I may try a first pass using
>>`replace-regexp' to replace all <img> links with inline mime image
>>attachments.
>
> Taking a look into the MIME specs (RFC2045ff) regarding this issue is
> on my list.  My biggest concern with utilizing more MIME capabilities
> is, that you have little control over what the recipient's MUA will do.
>

good point, for example as I recall gmail insists on displaying all
images at the bottom of an email message regardless of the placement of
their mime spec.  I wonder if it's possible for an html image link to
reference an attachment?

>
> Don't know about VM, but with regards to WL I'd imagine something
> like:
>
>  - first represent the MIME strukture in a list
>
>  - then call translating functions that insert the appropriate
>    delimeters
>

what does it look like (in the text WL buffer) when you attach say an
image, or a piece of inline text like a diff file?  If WL has it's own
mime markup like mml that would be ideal.

>
>>I've just made a couple of small changes, and pushed this file up to a
>>git repo at http://github.com/eschulte/org-html-mail, or for raw elisp
>>http://github.com/eschulte/org-html-mail/raw/master/org-mml-htmlize.el
>
> Just out of curiosity: Why do you write to a temp file and not just
> insert the body in a temporary buffer, turn on org-mode and use
> org-export-region-as-html (point-min) (point-max) nil t 'string)?
>

Because `org-export-as-html' requires that the buffer have a path, I
believe this is for resolution of relative paths for things like images.

Best -- Eric

>
>  -- David
>
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-24 20:19               ` Eric Schulte
@ 2010-03-25 21:17                 ` David Maus
  2010-03-26 14:53                   ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-03-25 21:17 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 602 bytes --]


Okay, took a look on the specs and attached is a memo on how an
implementation of org to MIME could be done.  The MIME delimiters of
SEMI and mml are quite similar so there's already a generic function
that creates representation of a MIME message for both.

I've published this memo on Worg, too, occupying some space in

http://orgmode.org/worg/org-devel.php

The tasks at hand would be: find the functions that attach a file in
mime-edit-mode and mml-mode and look who they can be utilized.

Best
 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de


[-- Attachment #1.1.2: Type: text/plain, Size: 8340 bytes --]


Author: David Maus <dmaus@ictsoc.de>
Date: 2010-03-25 21:56:50 CET


Table of Contents
=================
1 Representing a MIME internet message
2 MIME delimiters of SEMI and mml
3 Generic function
4 Open questions
    4.1 How to handle charset information?
    4.2 How to attach files?
5 Quotes from the specs
    5.1 MIME multipart: Notion of structured, related body parts
    5.2 MIME multipart: order of entities inside a multipart


1 Representing a MIME internet message
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   A MIME internet message consists of one or more MIME entities. Each
   MIME entity is of a distinct type and subtype, has a body and
   optional MIME headers related to it's content.

   A MIME entity is represented as a list:

   (TYPE SUBTYPE BODY CONT-HEAD)

   TYPE: Symbol of MIME media type (e.g. text, video, audio).

   SUBTYPE: Symbol of MIME media subtype (e.g. plain, html).

   BODY: String with entity body -or- list of other MIME entities.

   CONT-HEAD: List of cons with content related MIME header
                  fields.  The name of the header field without the
                  prefix "Content-" is car, the value cdr.

   Example:


  '(text html "<h1>Headline</h1>" ((disposition . inline)))

   For messages of type multipart the body consists of a list of one
   or more MIME entities.

  '(multipart alternative
              '((text plain "* Headline")
                (text html "<h1>headline</h1>")))

2 MIME delimiters of SEMI and mml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   The MIME delimiters are defined in an association list with a
   symbol of the library's name as key and delimiter format strings as
   values.  For each library there are three formatstrings.

   (SYMBOL DELIM-SINGLE DELIM-SINGLE-CONT DELIM-MULTI)

   DELIM-SINGLE: Denoting a single MIME entity.

                     Strings are passed in this order:

                     1. type

                     2. subtype

                     3. content header

                     4. body

   DELIM-SINGLE-CONT: Format of content header strings.

        Strings are passed in this order:

        1. header field name

        2. header field value

   DELIM-MULTI: Enclosing parts of a multipart entity.

                    Strings are passed in this order:

                    1. subtype

                    2. body

                    3. subtype


  (setq org-mail-htmlize-mime-delimiter-alist
        '((semi "\n- -[%s/%s%s]\n%s" "\ncontent-%s: %s" "\n- -<<%s>>-{\n%s\n- -}-<<%s>>")
          (mml "\n<#part type=\"%s/%s\"%s>\n%s" " %s=\"%s\"" "\n<#multipart type=\"%s\">\n%s\n<#/multipart>")))

3 Generic function
~~~~~~~~~~~~~~~~~~~

   This generic function returns a string representation with MIME
   delimiters depending on the variable =org-mail-htmlize-mime-lib=.


  (setq org-mail-htmlize-mime-lib 'semi)


  (defun org-mail-htmlize-mime-entity (type subtype body
                                            &optional cont-head)
    "Return string representation of MIME entity.

  TYPE is the type of entity body.
  SUBTYPE is the subtype of body.
  BODY is the body of the entity.  Either a string with the body
  content or a list with one ore more MIME entities.
  Optional argument CONT-HEAD is a list of cons with content
  specific headers, name in car and value in cdr."
    (let ((delimlst (assoc org-mail-htmlize-mime-lib
                           org-mail-htmlize-mime-delimiter-alist)))
      (if (eq type 'multipart)
          (format (nth 3 delimlst) subtype
                  (mapconcat '(lambda (b)
                                (apply 'org-mail-htmlize-mime-entity
                                       (car b) (cadr b) (cddr b)))
                             body "")
                  subtype)
        (format (nth 1 delimlst)
                type subtype
                (mapconcat '(lambda (h)
                              (format (nth 2 delimlst) (car h) (cdr h)))
                           cont-head "")
                body))))

4 Open questions
~~~~~~~~~~~~~~~~~

4.1 How to handle charset information?
=======================================

4.2 How to attach files?
=========================

    The generic function expects BODY either be a string or a list.
    Attaching binary file (image, etc.) requires to encode it so the
    message will pass the message system.  So we /might/ use kind of a
    encoder (e.g. base64) on our own.

    Or, what seems a cleaner solution: Use attachment function of the
    respective MIME mode.  To achive this: Introduce third possibility
    for BODY: A cons with the filename in car and symbol of the
    function in cdr.

    (FILENAME . FUNCTION)


  '(image jpeg ("/path/to/image" . org-mail-htmlize-add-attachment))

    The function =org-mail-htmlize-add-attachment= is called with file
    name as argument and calls the appropriate function depending on
    =org-mail-htmlize-mime-lib= and returns a string

       - with the encoded body

         -or-

       - the complete MIME entity

    Side effect: The user might be prompted for attachment settings
    (e.g. encoding).  But, on the other hand: We delegate the job of
    creating the attachment to the library that is responsible for
    mime.

5 Quotes from the specs
~~~~~~~~~~~~~~~~~~~~~~~~

5.1 MIME multipart: Notion of structured, related body parts
=============================================================

  -  [RFC2046, 5.1.1]

ORG-BLOCKQUOTE-START
NOTE:  Conspicuously missing from the "multipart" type is a notion of
structured, related body parts. It is recommended that those wishing
to provide more structured or integrated multipart messaging
facilities should define subtypes of multipart that are syntactically
identical but define relationships between the various parts. For
example, subtypes of multipart could be defined that include a
distinguished part which in turn is used to specify the relationships
between the other parts, probably referring to them by their
Content-ID field.  Old implementations will not recognize the new
subtype if this approach is used, but will treat it as
multipart/mixed and will thus be able to show the user the parts that
are recognized.
ORG-BLOCKQUOTE-END

[RFC2046, 5.1.1]: http://tools.ietf.org/html/rfc2046.html#section-5.1.1

5.2 MIME multipart: order of entities inside a multipart
=========================================================

  - [RFC2046, 5.1.3]

ORG-BLOCKQUOTE-START
5.1.3.  Mixed Subtype

   The "mixed" subtype of "multipart" is intended for use when the body
   parts are independent and need to be bundled in a particular order.
   Any "multipart" subtypes that an implementation does not recognize
   must be treated as being of subtype "mixed".

ORG-BLOCKQUOTE-END

  - [RFC2046, 5.1.4]

ORG-BLOCKQUOTE-START
5.1.4.  Alternative Subtype

   The "multipart/alternative" type is syntactically identical to
   "multipart/mixed", but the semantics are different.  In particular,
   each of the body parts is an "alternative" version of the same
   information.

   Systems should recognize that the content of the various parts are
   interchangeable.  Systems should choose the "best" type based on the
   local environment and references, in some cases even through user
   interaction.  As with "multipart/mixed", the order of body parts is
   significant.  In this case, the alternatives appear in an order of
   increasing faithfulness to the original content.  In general, the
   best choice is the LAST part of a type supported by the recipient
   system's local environment.
ORG-BLOCKQUOTE-END

ORG-BLOCKQUOTE-START
In general, user agents that compose "multipart/alternative" entities
must place the body parts in increasing order of preference, that is,
with the preferred format last.  For fancy text, the sending user
agent should put the plainest format first and the richest format
last.  Receiving user agents should pick and display the last format
they are capable of displaying.  In the case where one of the
alternatives is itself of type "multipart" and contains unrecognized
sub-parts, the user agent may choose either to show that alternative,
an earlier alternative, or both.
ORG-BLOCKQUOTE-END

[RFC2046, 5.1.3]: http://tools.ietf.org/html/rfc2046.html#section-5.1.3
[RFC2046, 5.1.4]: http://tools.ietf.org/html/rfc2046.html#section-5.1.4

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-25 21:17                 ` David Maus
@ 2010-03-26 14:53                   ` Eric Schulte
  2010-03-26 16:04                     ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-03-26 14:53 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 5 bytes --]

Hi,


[-- Attachment #2.1: Type: text/plain, Size: 647 bytes --]

So I believe inline LaTeX images are working in gnus, see here
$\sum{\text{ric}}$ and immediately below

$$
\frac{\sum_{n \in \text{daily tasks}}{n}}
{\text{Emacs}} = \text{Org-mode}
$$

This turned out to be fairly easy, and didn't require any encoding or
explicit mime function calls.

I've also re-structured the code so that it should be easy to apply the
appropriate mime markup for WL and VM.  There are now two mime-library
dependent functions `org-mail-file' and `org-mail-multipart' each of
which contains a `case' block for library-specific behavior, e.g.

#+begin_src emacs-lisp
  (case org-mail-mime-library
    ('mml (format (concat "

[-- Attachment #2.2.1: Type: text/plain, Size: 31 bytes --]

"
                          "%s

[-- Attachment #2.2.2: Type: text/html, Size: 2 bytes --]

[-- Attachment #2.3: Type: text/plain, Size: 267 bytes --]

                  plain html))
    ('semi "?")
    ('vm "?"))
#+end_src

everything is available at http://github.com/eschulte/org-html-mail

I'd love to hear feedback, suggestions, or expansion of the missing WL
and VM portions of the two functions mentioned above.

[-- Attachment #2.4: Type: text/html, Size: 1888 bytes --]

[-- Attachment #3: mail2517Uwd_bec399e15ff6f585494f84227a582a8056aca5a5.png --]
[-- Type: image/png, Size: 1288 bytes --]

[-- Attachment #4: mail2517Uwd_da7d4c60345e5ae9c5d477dbb9995ea627d66593.png --]
[-- Type: image/png, Size: 347 bytes --]

[-- Attachment #5: Type: text/plain, Size: 9962 bytes --]


David Maus <dmaus@ictsoc.de> writes:

> Okay, took a look on the specs and attached is a memo on how an
> implementation of org to MIME could be done.  The MIME delimiters of
> SEMI and mml are quite similar so there's already a generic function
> that creates representation of a MIME message for both.
>
> I've published this memo on Worg, too, occupying some space in
>
> http://orgmode.org/worg/org-devel.php
>

I took a look at this page, but it wasn't entirely clear to me what the
SEMI markup language should look like.  As mentioned above, for now I've
gone with `case' statements for each mime library, rather than an alist
of format strings -- in the off chance that different libraries could
require information in a different order.

>
> The tasks at hand would be: find the functions that attach a file in
> mime-edit-mode and mml-mode and look who they can be utilized.
>

I think that the mime markup libraries should handle attaching image
(including any encoding issues).  For example in gnus with mml only the
path to the image need be supplied.

>
> Best
>  -- David
>

Cheers -- Eric

>
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
>
>
> Author: David Maus <dmaus@ictsoc.de>
> Date: 2010-03-25 21:56:50 CET
>
>
> Table of Contents
> =================
> 1 Representing a MIME internet message
> 2 MIME delimiters of SEMI and mml
> 3 Generic function
> 4 Open questions
>     4.1 How to handle charset information?
>     4.2 How to attach files?
> 5 Quotes from the specs
>     5.1 MIME multipart: Notion of structured, related body parts
>     5.2 MIME multipart: order of entities inside a multipart
>
>
> 1 Representing a MIME internet message
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>    A MIME internet message consists of one or more MIME entities. Each
>    MIME entity is of a distinct type and subtype, has a body and
>    optional MIME headers related to it's content.
>
>    A MIME entity is represented as a list:
>
>    (TYPE SUBTYPE BODY CONT-HEAD)
>
>    TYPE: Symbol of MIME media type (e.g. text, video, audio).
>
>    SUBTYPE: Symbol of MIME media subtype (e.g. plain, html).
>
>    BODY: String with entity body -or- list of other MIME entities.
>
>    CONT-HEAD: List of cons with content related MIME header
>                   fields.  The name of the header field without the
>                   prefix "Content-" is car, the value cdr.
>
>    Example:
>
>
>   '(text html "<h1>Headline</h1>" ((disposition . inline)))
>
>    For messages of type multipart the body consists of a list of one
>    or more MIME entities.
>
>   '(multipart alternative
>               '((text plain "* Headline")
>                 (text html "<h1>headline</h1>")))
>
> 2 MIME delimiters of SEMI and mml
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>    The MIME delimiters are defined in an association list with a
>    symbol of the library's name as key and delimiter format strings as
>    values.  For each library there are three formatstrings.
>
>    (SYMBOL DELIM-SINGLE DELIM-SINGLE-CONT DELIM-MULTI)
>
>    DELIM-SINGLE: Denoting a single MIME entity.
>
>                      Strings are passed in this order:
>
>                      1. type
>
>                      2. subtype
>
>                      3. content header
>
>                      4. body
>
>    DELIM-SINGLE-CONT: Format of content header strings.
>
>         Strings are passed in this order:
>
>         1. header field name
>
>         2. header field value
>
>    DELIM-MULTI: Enclosing parts of a multipart entity.
>
>                     Strings are passed in this order:
>
>                     1. subtype
>
>                     2. body
>
>                     3. subtype
>
>
>   (setq org-mail-htmlize-mime-delimiter-alist
>         '((semi "\n- -[%s/%s%s]\n%s" "\ncontent-%s: %s" "\n- -<<%s>>-{\n%s\n- -}-<<%s>>")
>           (mml "\n<#part type=\"%s/%s\"%s>\n%s" " %s=\"%s\"" "\n<#multipart type=\"%s\">\n%s\n<#/multipart>")))
>
> 3 Generic function
> ~~~~~~~~~~~~~~~~~~~
>
>    This generic function returns a string representation with MIME
>    delimiters depending on the variable =org-mail-htmlize-mime-lib=.
>
>
>   (setq org-mail-htmlize-mime-lib 'semi)
>
>
>   (defun org-mail-htmlize-mime-entity (type subtype body
>                                             &optional cont-head)
>     "Return string representation of MIME entity.
>
>   TYPE is the type of entity body.
>   SUBTYPE is the subtype of body.
>   BODY is the body of the entity.  Either a string with the body
>   content or a list with one ore more MIME entities.
>   Optional argument CONT-HEAD is a list of cons with content
>   specific headers, name in car and value in cdr."
>     (let ((delimlst (assoc org-mail-htmlize-mime-lib
>                            org-mail-htmlize-mime-delimiter-alist)))
>       (if (eq type 'multipart)
>           (format (nth 3 delimlst) subtype
>                   (mapconcat '(lambda (b)
>                                 (apply 'org-mail-htmlize-mime-entity
>                                        (car b) (cadr b) (cddr b)))
>                              body "")
>                   subtype)
>         (format (nth 1 delimlst)
>                 type subtype
>                 (mapconcat '(lambda (h)
>                               (format (nth 2 delimlst) (car h) (cdr h)))
>                            cont-head "")
>                 body))))
>
> 4 Open questions
> ~~~~~~~~~~~~~~~~~
>
> 4.1 How to handle charset information?
> =======================================
>
> 4.2 How to attach files?
> =========================
>
>     The generic function expects BODY either be a string or a list.
>     Attaching binary file (image, etc.) requires to encode it so the
>     message will pass the message system.  So we /might/ use kind of a
>     encoder (e.g. base64) on our own.
>
>     Or, what seems a cleaner solution: Use attachment function of the
>     respective MIME mode.  To achive this: Introduce third possibility
>     for BODY: A cons with the filename in car and symbol of the
>     function in cdr.
>
>     (FILENAME . FUNCTION)
>
>
>   '(image jpeg ("/path/to/image" . org-mail-htmlize-add-attachment))
>
>     The function =org-mail-htmlize-add-attachment= is called with file
>     name as argument and calls the appropriate function depending on
>     =org-mail-htmlize-mime-lib= and returns a string
>
>        - with the encoded body
>
>          -or-
>
>        - the complete MIME entity
>
>     Side effect: The user might be prompted for attachment settings
>     (e.g. encoding).  But, on the other hand: We delegate the job of
>     creating the attachment to the library that is responsible for
>     mime.
>
> 5 Quotes from the specs
> ~~~~~~~~~~~~~~~~~~~~~~~~
>
> 5.1 MIME multipart: Notion of structured, related body parts
> =============================================================
>
>   -  [RFC2046, 5.1.1]
>
> ORG-BLOCKQUOTE-START
> NOTE:  Conspicuously missing from the "multipart" type is a notion of
> structured, related body parts. It is recommended that those wishing
> to provide more structured or integrated multipart messaging
> facilities should define subtypes of multipart that are syntactically
> identical but define relationships between the various parts. For
> example, subtypes of multipart could be defined that include a
> distinguished part which in turn is used to specify the relationships
> between the other parts, probably referring to them by their
> Content-ID field.  Old implementations will not recognize the new
> subtype if this approach is used, but will treat it as
> multipart/mixed and will thus be able to show the user the parts that
> are recognized.
> ORG-BLOCKQUOTE-END
>
> [RFC2046, 5.1.1]: http://tools.ietf.org/html/rfc2046.html#section-5.1.1
>
> 5.2 MIME multipart: order of entities inside a multipart
> =========================================================
>
>   - [RFC2046, 5.1.3]
>
> ORG-BLOCKQUOTE-START
> 5.1.3.  Mixed Subtype
>
>    The "mixed" subtype of "multipart" is intended for use when the body
>    parts are independent and need to be bundled in a particular order.
>    Any "multipart" subtypes that an implementation does not recognize
>    must be treated as being of subtype "mixed".
>
> ORG-BLOCKQUOTE-END
>
>   - [RFC2046, 5.1.4]
>
> ORG-BLOCKQUOTE-START
> 5.1.4.  Alternative Subtype
>
>    The "multipart/alternative" type is syntactically identical to
>    "multipart/mixed", but the semantics are different.  In particular,
>    each of the body parts is an "alternative" version of the same
>    information.
>
>    Systems should recognize that the content of the various parts are
>    interchangeable.  Systems should choose the "best" type based on the
>    local environment and references, in some cases even through user
>    interaction.  As with "multipart/mixed", the order of body parts is
>    significant.  In this case, the alternatives appear in an order of
>    increasing faithfulness to the original content.  In general, the
>    best choice is the LAST part of a type supported by the recipient
>    system's local environment.
> ORG-BLOCKQUOTE-END
>
> ORG-BLOCKQUOTE-START
> In general, user agents that compose "multipart/alternative" entities
> must place the body parts in increasing order of preference, that is,
> with the preferred format last.  For fancy text, the sending user
> agent should put the plainest format first and the richest format
> last.  Receiving user agents should pick and display the last format
> they are capable of displaying.  In the case where one of the
> alternatives is itself of type "multipart" and contains unrecognized
> sub-parts, the user agent may choose either to show that alternative,
> an earlier alternative, or both.
> ORG-BLOCKQUOTE-END
>
> [RFC2046, 5.1.3]: http://tools.ietf.org/html/rfc2046.html#section-5.1.3
> [RFC2046, 5.1.4]: http://tools.ietf.org/html/rfc2046.html#section-5.1.4

[-- Attachment #6: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-26 14:53                   ` Eric Schulte
@ 2010-03-26 16:04                     ` David Maus
  2010-03-26 16:32                       ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-03-26 16:04 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 3623 bytes --]

Eric Schulte wrote:
>So I believe inline LaTeX images are working in gnus, see here
>[cid]    and immediately below

>[cid]

>This turned out to be fairly easy, and didn't require any encoding or
>explicit mime function calls.

>I've also re-structured the code so that it should be easy to apply the
>appropriate mime markup for WL and VM. There are now two mime-library
>dependent functions `org-mail-file' and `org-mail-multipart' each of
>which contains a `case' block for library-specific behavior, e.g.

>(case org-mail-mime-library
>  ('mml (format (concat "<#multipart type=alternative><#part type=text/plain>"
>                        "%s<#part type=text/html>%s<#/multipart>\n")
>                plain html))
>  ('semi "?")
>  ('vm "?"))

>everything is available at http://github.com/eschulte/org-html-mail

>I'd love to hear feedback, suggestions, or expansion of the missing WL
>and VM portions of the two functions mentioned above.

Two remarks:

1st/

,----
| (add-to-list 'html-images
|              (org-mail-file (concat "image/" ext) path id))
`----

Using the file extension as subtype is not in compliance with the
specs.  For instance the MIME type of "filename.jpg" is image/jpeg,
not image/jpg (cf. RFC 2046, 4.2).

What you need is kind of a function or software that returns MIME type
of a file name.  In SEMI it's `mime-find-file-type'.  Or maybe don't
set the type, maybe mml will pick a type for you.

2nd/

The usage of multipart/alternative is not in compliance with the
specs, too.  There it reads:

RFC2046, 5.1.4

,----
| 5.1.4. Alternative Subtype
|
| The "multipart/alternative" type is syntactically identical to
| "multipart/mixed", but the semantics are different. In particular,
| each of the body parts is an "alternative" version of the same
| information.
|
| Systems should recognize that the content of the various parts are
| interchangeable. Systems should choose the "best" type based on the
| local environment and references, in some cases even through user
| interaction. As with "multipart/mixed", the order of body parts is
| significant. In this case, the alternatives appear in an order of
| increasing faithfulness to the original content. In general, the best
| choice is the LAST part of a type supported by the recipient system's
| local environment.
|
| In general, user agents that compose "multipart/alternative" entities
| must place the body parts in increasing order of preference, that is,
| with the preferred format last. For fancy text, the sending user agent
| should put the plainest format first and the richest format
| last. Receiving user agents should pick and display the last format
| they are capable of displaying. In the case where one of the
| alternatives is itself of type "multipart" and contains unrecognized
| sub-parts, the user agent may choose either to show that alternative,
| an earlier alternative, or both.
`----

So if you attach *only a part* of the plain text message body, you
should not use multipart/alternative: Because

  1. a part of a message is not "an 'alternative' version of the same
     information."

  2. if recipients user agent prefers html messages it will display
     only the html'ized part.

Better use multipart/alternative for plain text and html of the entire
body and additional multipart/mixed for snippets.  If the html output
should contain images, than maybe use a multipart/mixed with type
text/html beneath the text/plain, so the receiving MUA might pick it
up when prefering html.

With regards to SEMI the delimiters are (inserted a space between two
succeeding dashes):

 - single entity:


[-- Attachment #1.1.2: Type: type/subtype, Size: 779 bytes --]

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-26 16:04                     ` David Maus
@ 2010-03-26 16:32                       ` Eric Schulte
  2010-03-31 18:12                         ` [CONTRIB?] " Eric Schulte
  2010-03-31 20:37                         ` David Maus
  0 siblings, 2 replies; 63+ messages in thread
From: Eric Schulte @ 2010-03-26 16:32 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, emacs-orgmode

Hi David,

David Maus <dmaus@ictsoc.de> writes:

[...]

> Two remarks:
>
> 1st/
>
> ,----
> | (add-to-list 'html-images
> |              (org-mail-file (concat "image/" ext) path id))
> `----
>
> Using the file extension as subtype is not in compliance with the
> specs.  For instance the MIME type of "filename.jpg" is image/jpeg,
> not image/jpg (cf. RFC 2046, 4.2).
>
> What you need is kind of a function or software that returns MIME type
> of a file name.  In SEMI it's `mime-find-file-type'.  Or maybe don't
> set the type, maybe mml will pick a type for you.
>

Ah thanks, I will look to see if there is such a function distributed
with the core Emacs, else a simple alist should suffice.

>
> 2nd/
>
> The usage of multipart/alternative is not in compliance with the
> specs, too.  There it reads:
>
> RFC2046, 5.1.4
>
> ,----
> | 5.1.4. Alternative Subtype
> |
> | The "multipart/alternative" type is syntactically identical to
> | "multipart/mixed", but the semantics are different. In particular,
> | each of the body parts is an "alternative" version of the same
> | information.
> |
> | Systems should recognize that the content of the various parts are
> | interchangeable. Systems should choose the "best" type based on the
> | local environment and references, in some cases even through user
> | interaction. As with "multipart/mixed", the order of body parts is
> | significant. In this case, the alternatives appear in an order of
> | increasing faithfulness to the original content. In general, the best
> | choice is the LAST part of a type supported by the recipient system's
> | local environment.
> |
> | In general, user agents that compose "multipart/alternative" entities
> | must place the body parts in increasing order of preference, that is,
> | with the preferred format last. For fancy text, the sending user agent
> | should put the plainest format first and the richest format
> | last. Receiving user agents should pick and display the last format
> | they are capable of displaying. In the case where one of the
> | alternatives is itself of type "multipart" and contains unrecognized
> | sub-parts, the user agent may choose either to show that alternative,
> | an earlier alternative, or both.
> `----
>
> So if you attach *only a part* of the plain text message body, you
> should not use multipart/alternative: Because
>
>   1. a part of a message is not "an 'alternative' version of the same
>      information."
>
>   2. if recipients user agent prefers html messages it will display
>      only the html'ized part.
>

I should have been clearer here.  I *am* using the multipart/alternative
appropriately.  When a chunk of org-mode text is converted to html I am
adding a single multipart/alternative block with two alternatives, both
the plain org-mode text, and the html, so that users like me who prefer
to see plain text can do so, and users of web clients like gmail can see
nice markup.

>
> Better use multipart/alternative for plain text and html of the entire
> body and additional multipart/mixed for snippets.  If the html output
> should contain images, than maybe use a multipart/mixed with type
> text/html beneath the text/plain, so the receiving MUA might pick it
> up when prefering html.
>
> With regards to SEMI the delimiters are (inserted a space between two
> succeeding dashes):
>
>  - single entity:

And the limits of user email to discuss email have been reached :)

gnus seems to have mangled some of the following examples, but I have
tried to flesh out the 'semi portions org-mail-htmlize given what I was
able to salvage (see the latest commit).  I still can't figure out the
SEMI multipart/alternative syntax.  Please let me know if you have the
syntax at hand, feel like submitting a patch, or you would like commit
permission to the git repo.

Much Thanks! -- Eric

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-03-26 16:32                       ` Eric Schulte
@ 2010-03-31 18:12                         ` Eric Schulte
  2010-03-31 20:05                           ` Dan Davison
                                             ` (2 more replies)
  2010-03-31 20:37                         ` David Maus
  1 sibling, 3 replies; 63+ messages in thread
From: Eric Schulte @ 2010-03-31 18:12 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I've been using the code currently located at [1] for sending HTML email
[2] for a little while now, and it is working very well.

I wonder if this should be included in the contrib directory of
Org-mode?  Also, since it currently only supports gnus (it should be
very easy to extend to WL and VM, but I don't have access to these other
mailers for testing/verification) maybe it should be sent to the gnus
mailing list instead?

Cheers -- Eric

Footnotes: 
[1]  http://github.com/eschulte/org-html-mail

[2] In defense of sending html mail I should mention that I've only been
    using it to send tables and latex images to people who I know don't
    have access to a true fixed-width font email client.  In addition
    the code presents html as one multipart/alternative with the full
    org-mode plain text presented as a text alternative, so those who
    care and who have control over their email clients can opt to view
    the text portion and ignore the html.  In gnus this is possible with
    
    (setq mm-discouraged-alternatives '("text/html" "text/richtext"))

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-03-31 18:12                         ` [CONTRIB?] " Eric Schulte
@ 2010-03-31 20:05                           ` Dan Davison
  2010-03-31 21:10                             ` Eric Schulte
  2010-04-01 17:37                           ` Sivaram Neelakantan
  2010-04-01 17:45                           ` Sivaram Neelakantan
  2 siblings, 1 reply; 63+ messages in thread
From: Dan Davison @ 2010-03-31 20:05 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Hi,
>
> I've been using the code currently located at [1] for sending HTML email
> [2] for a little while now, and it is working very well.

Hi Eric,

I just tried pasting content from an org file into a message-mode buffer
and calling org-mail-htmlize on the region, and sending the resulting
message to gmail. It worked very nicely, with two drawbacks:

1. The content contained links to an image like [[file:file.png][]]. I
   had to manually copy the image to /tmp in order for it to be found on
   sending.

2. The TODO keywords and timestamps lacked their org-mode fontification.

Is there a different procedure I should use to do what I'm trying to do,
or are these tweaks that could be made to your code? I have not
attempted to follow the technical aspects of this thread so I may well
be misunderstanding stuff here.

Thanks!

Dan



>
> I wonder if this should be included in the contrib directory of
> Org-mode?  Also, since it currently only supports gnus (it should be
> very easy to extend to WL and VM, but I don't have access to these other
> mailers for testing/verification) maybe it should be sent to the gnus
> mailing list instead?
>
> Cheers -- Eric
>
> Footnotes: 
> [1]  http://github.com/eschulte/org-html-mail
>
> [2] In defense of sending html mail I should mention that I've only been
>     using it to send tables and latex images to people who I know don't
>     have access to a true fixed-width font email client.  In addition
>     the code presents html as one multipart/alternative with the full
>     org-mode plain text presented as a text alternative, so those who
>     care and who have control over their email clients can opt to view
>     the text portion and ignore the html.  In gnus this is possible with
>     
>     (setq mm-discouraged-alternatives '("text/html" "text/richtext"))
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-26 16:32                       ` Eric Schulte
  2010-03-31 18:12                         ` [CONTRIB?] " Eric Schulte
@ 2010-03-31 20:37                         ` David Maus
  2010-03-31 22:03                           ` Eric Schulte
  2010-04-01  7:53                           ` Vagn Johansen
  1 sibling, 2 replies; 63+ messages in thread
From: David Maus @ 2010-03-31 20:37 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 3732 bytes --]

Eric Schulte wrote:
>Hi David,
> [...]
>>
>> 2nd/
>>
>> The usage of multipart/alternative is not in compliance with the
>> specs, too.  There it reads:
>>
>> [...]
>>
>> So if you attach *only a part* of the plain text message body, you
>> should not use multipart/alternative: Because
>>
>>   1. a part of a message is not "an 'alternative' version of the same
>>      information."
>>
>>   2. if recipients user agent prefers html messages it will display
>>      only the html'ized part.
>>

>I should have been clearer here.  I *am* using the multipart/alternative
>appropriately.  When a chunk of org-mode text is converted to html I am
>adding a single multipart/alternative block with two alternatives, both
>the plain org-mode text, and the html, so that users like me who prefer
>to see plain text can do so, and users of web clients like gmail can see
>nice markup.

Okay, should have looked closer to the code.

1/

But I still feel uncomfortable with the current solution: Even if the
message created by current org-mail-htmlize is a valid MIME message (I
think so) it is a rather complex MIME structure and I have no idea how
other MUAs will display such a message.

Moreover, this complexity is unecessary if we make the assumption:

  If substantial parts of your message require html markup do be
  displayed by a some of your recipients, than send a html
  representation of the entire message along with the plain text.[1]

For a recipient who preferes html the result is the same: For him the
substantial parts are displayed in a meaningful way.  People who
prefer or depend on plain text get the plain text.  And we avoid
uneccesary complexity.

Thinking functional this might be the first function of
org-mail-htmlize[1]: Create a html representation of message body if
necessary or appropriate.

2/

The second function: Attach external files that are referenced in the
message.  This might be useful even if you don't send out html
messages: All external files are stashed into a multipart/mixed
container along with a Content-Id: header field.

Than all references are changed accordingly to point to the attached
files:

  - for html use src/href with the cid: prefix

  - for text: good question.  Maybe replace occurences of the file
    with a customizable string saying: "see attached file foo.bar".

3/

For Wanderlust multipart/alternative is (replace "_" by "-")

__<<alternative>>_{

and closing

__}_<<alternative>>

4/

Detecting the plain text body should not just stop on end of buffer
but also on the first occurence of a MIME delimiter: Maybe the user
already added a attachment.

And, last not least: This has the potential for going into contrib.
Maybe it should be renamed to org-mime -- it's neither just about
mail, nor just about htmlizing.

HTH
  -- David

[1] This assumption may also address the concerns about sending html
messages: From my perspective html message are not a problem in
itself.  Sometimes people have to send html messages (organizational
rules) and sometimes it is appropriate for content to render properly.
As far as I read on the topic of html message they got their bad name
because people where sending html messages implicitely assuming that
all recipients /can/ read them in the same "fancy" format as they did.
Such an assumtion is wrong because it does not take into account that
information and it's representation are two different things and
computers are create in processing and (re)formatting information.

Anyway, what org-mail-htmlize really misses is a function that adds
fance pictures (cats!), sounds and maybe even flash animations to the
messages :D



--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-03-31 20:05                           ` Dan Davison
@ 2010-03-31 21:10                             ` Eric Schulte
  2010-03-31 21:37                               ` Dan Davison
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-03-31 21:10 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Dan Davison <davison@stats.ox.ac.uk> writes:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Hi,
>>
>> I've been using the code currently located at [1] for sending HTML email
>> [2] for a little while now, and it is working very well.
>
> Hi Eric,
>
> I just tried pasting content from an org file into a message-mode buffer
> and calling org-mail-htmlize on the region, and sending the resulting
> message to gmail. It worked very nicely, with two drawbacks:
>
> 1. The content contained links to an image like [[file:file.png][]]. I
>    had to manually copy the image to /tmp in order for it to be found on
>    sending.
>

As the mail composition buffer doesn't really live on the file system
relative paths will not work.  I believe specifying an absolute path to
the image would work, or as you mentioned during export the mail buffer
is written to the /tmp directory, so basing relative paths there will
also work.  I think this behavior is sufficient, and can't think of any
good alternative.

Note that images generated during export to html (e.g. latex images,
babel images, etc...) will be resolved correctly.

>
> 2. The TODO keywords and timestamps lacked their org-mode
>fontification.
>

Ah yes, sites like gmail are careful not to allow page-wide css in HTML
mail.  All css must be embedded into specific html elements (e.g. <pre
style="...">).  This is reasonable on their parts as a malicious email
could destroy the rendering of the web interface.

>
> Is there a different procedure I should use to do what I'm trying to
>do, or are these tweaks that could be made to your code? I have not
>attempted to follow the technical aspects of this thread so I may well
>be misunderstanding stuff here.
>

There is a hook provided in the supplied code, currently called
`org-mail-html-hook' which you can use to doctor the final html.  For
example I use the following to force a dark background on all my code
blocks.

--8<---------------cut here---------------start------------->8---
;; example hook, for setting a dark background in <pre style="background-color: #EEE;"> elements
(defun org-mail-change-pre-colors (foreground background)
  "Set new default htlm colors for <pre> elements in exported html mail."
  (while (re-search-forward "<pre" nil t)
    (replace-match
     (format "<pre style=\"color: %s; background-color: %s;\""
             foreground background))))

;; example addition to `org-mail-html-hook' adding a dark background
;; color to <pre> elements
(add-hook 'org-mail-html-hook
          (lambda ()
            (org-mail-change-pre-colors "#E6E1DC" "#232323")))
--8<---------------cut here---------------end--------------->8---

An extension of this could be used to add missing CSS elements where
required.

Best -- Eric

>
> Thanks!
>
> Dan
>
>
>
>>
>> I wonder if this should be included in the contrib directory of
>> Org-mode?  Also, since it currently only supports gnus (it should be
>> very easy to extend to WL and VM, but I don't have access to these other
>> mailers for testing/verification) maybe it should be sent to the gnus
>> mailing list instead?
>>
>> Cheers -- Eric
>>
>> Footnotes: 
>> [1]  http://github.com/eschulte/org-html-mail
>>
>> [2] In defense of sending html mail I should mention that I've only been
>>     using it to send tables and latex images to people who I know don't
>>     have access to a true fixed-width font email client.  In addition
>>     the code presents html as one multipart/alternative with the full
>>     org-mode plain text presented as a text alternative, so those who
>>     care and who have control over their email clients can opt to view
>>     the text portion and ignore the html.  In gnus this is possible with
>>     
>>     (setq mm-discouraged-alternatives '("text/html" "text/richtext"))
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please 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] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-03-31 21:10                             ` Eric Schulte
@ 2010-03-31 21:37                               ` Dan Davison
  2010-04-01 14:22                                 ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Dan Davison @ 2010-03-31 21:37 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Dan Davison <davison@stats.ox.ac.uk> writes:
>
>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>
>>> Hi,
>>>
>>> I've been using the code currently located at [1] for sending HTML email
>>> [2] for a little while now, and it is working very well.
>>
>> Hi Eric,
>>
>> I just tried pasting content from an org file into a message-mode buffer
>> and calling org-mail-htmlize on the region, and sending the resulting
>> message to gmail. It worked very nicely, with two drawbacks:
>>
>> 1. The content contained links to an image like [[file:file.png][]]. I
>>    had to manually copy the image to /tmp in order for it to be found on
>>    sending.
>>
>
> As the mail composition buffer doesn't really live on the file system
> relative paths will not work.  I believe specifying an absolute path to
> the image would work, or as you mentioned during export the mail buffer
> is written to the /tmp directory, so basing relative paths there will
> also work.  I think this behavior is sufficient, and can't think of any
> good alternative.

As I understand it the code you've written is designed to be called in a
message-mode buffer with orgstruct-mode in force. Would it make sense to
also include in your package a complementary function, that one calls in
an org-mode buffer? I envisage this generating the HTML, forming the
multipart email contents, and then saving it to the kill ring, so that
it can be pasted into an email.

This function would have access to the directory-name and so should be
able to resolve relative paths. Also, there might be some other
advantages -- for example when exporting just a region or subtree,
buffer-wide properties such as #+TITLE and #+AUTHOR are picked up by the
org exporter and packaged into the HTML.

In other words, can I use your machinery to package up the HTML
generated by Org's C-e dispatcher into an appropriately-constructed
email?

>
> Note that images generated during export to html (e.g. latex images,
> babel images, etc...) will be resolved correctly.
>
>>
>> 2. The TODO keywords and timestamps lacked their org-mode
>>fontification.
>>
>
> Ah yes, sites like gmail are careful not to allow page-wide css in HTML
> mail.  All css must be embedded into specific html elements (e.g. <pre
> style="...">).  This is reasonable on their parts as a malicious email
> could destroy the rendering of the web interface.

I see.

>
>>
>> Is there a different procedure I should use to do what I'm trying to
>>do, or are these tweaks that could be made to your code? I have not
>>attempted to follow the technical aspects of this thread so I may well
>>be misunderstanding stuff here.
>>
>
> There is a hook provided in the supplied code, currently called
> `org-mail-html-hook' which you can use to doctor the final html.  For
> example I use the following to force a dark background on all my code
> blocks.
>
> ;; example hook, for setting a dark background in <pre style="background-color: #EEE;"> elements
> (defun org-mail-change-pre-colors (foreground background)
>   "Set new default htlm colors for <pre> elements in exported html mail."
>   (while (re-search-forward "<pre" nil t)
>     (replace-match
>      (format "<pre style=\"color: %s; background-color: %s;\""
>              foreground background))))
>
> ;; example addition to `org-mail-html-hook' adding a dark background
> ;; color to <pre> elements
> (add-hook 'org-mail-html-hook
>           (lambda ()
>             (org-mail-change-pre-colors "#E6E1DC" "#232323")))
>
> An extension of this could be used to add missing CSS elements where
> required.

OK, thanks for that.

Dan

>
> Best -- Eric
>
>>
>> Thanks!
>>
>> Dan
>>
>>
>>
>>>
>>> I wonder if this should be included in the contrib directory of
>>> Org-mode?  Also, since it currently only supports gnus (it should be
>>> very easy to extend to WL and VM, but I don't have access to these other
>>> mailers for testing/verification) maybe it should be sent to the gnus
>>> mailing list instead?
>>>
>>> Cheers -- Eric
>>>
>>> Footnotes: 
>>> [1]  http://github.com/eschulte/org-html-mail
>>>
>>> [2] In defense of sending html mail I should mention that I've only been
>>>     using it to send tables and latex images to people who I know don't
>>>     have access to a true fixed-width font email client.  In addition
>>>     the code presents html as one multipart/alternative with the full
>>>     org-mode plain text presented as a text alternative, so those who
>>>     care and who have control over their email clients can opt to view
>>>     the text portion and ignore the html.  In gnus this is possible with
>>>     
>>>     (setq mm-discouraged-alternatives '("text/html" "text/richtext"))
>>>
>>>
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Please use `Reply All' to send replies to the list.
>>> Emacs-orgmode@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-31 20:37                         ` David Maus
@ 2010-03-31 22:03                           ` Eric Schulte
  2010-04-02  7:04                             ` David Maus
  2010-04-01  7:53                           ` Vagn Johansen
  1 sibling, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-03-31 22:03 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

[...]

> 1/
>
> But I still feel uncomfortable with the current solution: Even if the
> message created by current org-mail-htmlize is a valid MIME message (I
> think so) it is a rather complex MIME structure and I have no idea how
> other MUAs will display such a message.
>

Yes, but since it is valid MIME I'm personally very happy with it.  Also
both Gmail and Gnus both play well with these complex embedded multipart
structures.  Unless it actually becomes a problem I don't see any reason
not to use the standard to it's full power.

>
> Moreover, this complexity is unecessary if we make the assumption:
>
>   If substantial parts of your message require html markup do be
>   displayed by a some of your recipients, than send a html
>   representation of the entire message along with the plain text.[1]
>

I don't agree with that assumption :)

I often want only a table, list, or latex-heavy section of my email to
be converted to html.  I find that other parts of the email
(e.g. previous emails in the thread nested behind ">" characters,
signatures, etc...)  work better when sent as pure text.

>
> For a recipient who preferes html the result is the same: For him the
> substantial parts are displayed in a meaningful way.  People who
> prefer or depend on plain text get the plain text.  And we avoid
> uneccesary complexity.
>
> Thinking functional this might be the first function of
> org-mail-htmlize[1]: Create a html representation of message body if
> necessary or appropriate.
>

Oh, so this would be a slightly different issue,

So this function could be run *every* time an email is sent.  I agree
that in those cases running on the entire message would be the right way
to go.  Currently if `org-mail-htmlize' is called with no active region
then this is what happens.  So I believe the code as currently written
should satisfy the above points, resulting in a simple structure (only
one multipart/alternative section) which contains the entire email and
would be appropriate for running on every mail sent.

>
> 2/
>
> The second function: Attach external files that are referenced in the
> message.  This might be useful even if you don't send out html
> messages: All external files are stashed into a multipart/mixed
> container along with a Content-Id: header field.
>
> Than all references are changed accordingly to point to the attached
> files:
>
>   - for html use src/href with the cid: prefix
>
>   - for text: good question.  Maybe replace occurences of the file
>     with a customizable string saying: "see attached file foo.bar".
>

I'm not sure I understand, I'm currently happy with my mail agent's
method of attaching files to email, what else would this use of the
function add aside from a new attachment syntax.

>
> 3/
>
> For Wanderlust multipart/alternative is (replace "_" by "-")
>

Thanks, I've applied this to the `org-mail-multipart' function in the
code repository.  I'm not entirely sure if I got the full multipart
syntax correct, but if I did then hopefully this means that WL is now
supported.

>
> __<<alternative>>_{
>
> and closing
>
> __}_<<alternative>>
>
> 4/
>
> Detecting the plain text body should not just stop on end of buffer
> but also on the first occurence of a MIME delimiter: Maybe the user
> already added a attachment.
>

Good point, one open question here is how to treat that mime border, I'm
thinking it may be best to simply stash it in a

#+BEGIN_HTML
original mime content
#+END_HTML

block, so that it survives the Org-mode export unscathed, however maybe
it's simpler just to end the html alternative part at the first mime
border.

Either way this will require a mailer specific function to search for
the next multipart section.

>
> And, last not least: This has the potential for going into contrib.
> Maybe it should be renamed to org-mime -- it's neither just about
> mail, nor just about htmlizing.
>

Fair point.  I've just renamed the functions and the repository, and it
is now available at [1].  If there's a better place to host this to
encourage collaboration please let me know.

Thanks -- Eric

>
> HTH
>   -- David
>
> [1] This assumption may also address the concerns about sending html
> messages: From my perspective html message are not a problem in
> itself.  Sometimes people have to send html messages (organizational
> rules) and sometimes it is appropriate for content to render properly.
> As far as I read on the topic of html message they got their bad name
> because people where sending html messages implicitely assuming that
> all recipients /can/ read them in the same "fancy" format as they did.
> Such an assumtion is wrong because it does not take into account that
> information and it's representation are two different things and
> computers are create in processing and (re)formatting information.
>
> Anyway, what org-mail-htmlize really misses is a function that adds
> fance pictures (cats!), sounds and maybe even flash animations to the
> messages :D
>

:) agreed, blink tags around every noun

>
>
>
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de

Footnotes: 
[1]  http://github.com/eschulte/org-mime

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-31 20:37                         ` David Maus
  2010-03-31 22:03                           ` Eric Schulte
@ 2010-04-01  7:53                           ` Vagn Johansen
  2010-04-02  6:34                             ` David Maus
  1 sibling, 1 reply; 63+ messages in thread
From: Vagn Johansen @ 2010-04-01  7:53 UTC (permalink / raw)
  To: emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

> Eric Schulte wrote:

[...]

>>I should have been clearer here.  I *am* using the multipart/alternative
>>appropriately.  When a chunk of org-mode text is converted to html I am
>>adding a single multipart/alternative block with two alternatives, both
>>the plain org-mode text, and the html, so that users like me who prefer
>>to see plain text can do so, and users of web clients like gmail can see
>>nice markup.

[...]

> But I still feel uncomfortable with the current solution: Even if the
> message created by current org-mail-htmlize is a valid MIME message (I
> think so) it is a rather complex MIME structure and I have no idea how
> other MUAs will display such a message.

Complex? That is how most emails are structured today.

-- 
Vagn Johansen

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-03-31 21:37                               ` Dan Davison
@ 2010-04-01 14:22                                 ` Eric Schulte
  2010-04-05  5:39                                   ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-01 14:22 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Dan Davison <davison@stats.ox.ac.uk> writes:

[...]

>
> As I understand it the code you've written is designed to be called in a
> message-mode buffer with orgstruct-mode in force. Would it make sense to
> also include in your package a complementary function, that one calls in
> an org-mode buffer? I envisage this generating the HTML, forming the
> multipart email contents, and then saving it to the kill ring, so that
> it can be pasted into an email.
>
> This function would have access to the directory-name and so should be
> able to resolve relative paths. Also, there might be some other
> advantages -- for example when exporting just a region or subtree,
> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up by the
> org exporter and packaged into the HTML.
>
> In other words, can I use your machinery to package up the HTML
> generated by Org's C-e dispatcher into an appropriately-constructed
> email?
>

Hi Dan,

That sounds like a good idea, I've added it to a fledgling task list
packaged in the README at [1].  I'd say there are two options.

1) which you mentioned saving the entire exported content to the
   kill-ring.  One problem here is that everything is still text and
   pastable only *before* the mime export process, which means that
   linked images wouldn't resolve after pasting into the email client.

2) having the function generate a new mail buffer containing the
   exported content.  This buffer would need to have it's
   `buffer-file-name' set, for images to resolve during export.  I'm not
   sure how this should best work.

Thanks -- Eric

Footnotes: 
[1]  http://github.com/eschulte/org-mime

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-03-31 18:12                         ` [CONTRIB?] " Eric Schulte
  2010-03-31 20:05                           ` Dan Davison
@ 2010-04-01 17:37                           ` Sivaram Neelakantan
  2010-04-01 17:45                           ` Sivaram Neelakantan
  2 siblings, 0 replies; 63+ messages in thread
From: Sivaram Neelakantan @ 2010-04-01 17:37 UTC (permalink / raw)
  To: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Hi,
>
> I've been using the code currently located at [1] for sending HTML email
> [2] for a little while now, and it is working very well.
>
> I wonder if this should be included in the contrib directory of
> Org-mode?  Also, since it currently only supports gnus (it should be
> very easy to extend to WL and VM, but I don't have access to these other
> mailers for testing/verification) maybe it should be sent to the gnus
> mailing list instead?
>

Please do.  Whether gnus committers would add it in is another thing
but it wouldn't hurt to post to the gnus lists of such a facility.

And could you also post on the gnu.Emacs.sources newsgroup so that
people know of it there too?


[snipped 22 lines]

 sivaram
 -- 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-03-31 18:12                         ` [CONTRIB?] " Eric Schulte
  2010-03-31 20:05                           ` Dan Davison
  2010-04-01 17:37                           ` Sivaram Neelakantan
@ 2010-04-01 17:45                           ` Sivaram Neelakantan
  2 siblings, 0 replies; 63+ messages in thread
From: Sivaram Neelakantan @ 2010-04-01 17:45 UTC (permalink / raw)
  To: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:


[snipped 13 lines]

> Footnotes: 
> [1]  http://github.com/eschulte/org-html-mail
>
Presumably, you meant http://github.com/eschulte/org-mime as your link
does not work.

[snipped 18 lines]

 sivaram
 -- 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-01  7:53                           ` Vagn Johansen
@ 2010-04-02  6:34                             ` David Maus
  2010-04-02 14:57                               ` Dan Davison
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-04-02  6:34 UTC (permalink / raw)
  To: Vagn Johansen; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 3677 bytes --]

Vagn Johansen wrote:
>David Maus <dmaus@ictsoc.de> writes:

>> Eric Schulte wrote:

>[...]

>>>I should have been clearer here.  I *am* using the multipart/alternative
>>>appropriately.  When a chunk of org-mode text is converted to html I am
>>>adding a single multipart/alternative block with two alternatives, both
>>>the plain org-mode text, and the html, so that users like me who prefer
>>>to see plain text can do so, and users of web clients like gmail can see
>>>nice markup.

>[...]

>> But I still feel uncomfortable with the current solution: Even if the
>> message created by current org-mail-htmlize is a valid MIME message (I
>> think so) it is a rather complex MIME structure and I have no idea how
>> other MUAs will display such a message.

>Complex? That is how most emails are structured today.

I cannot not speak of "most emails today" but grepping for the
multipart/ entity in my mail archive ranging back to 2003 gives:


 | multipart entities in message | number of messages |
 |-------------------------------+--------------------|
 |                             0 |               4208 |
 |                             1 |               3587 |
 |                             2 |                260 |
 |                             3 |                  8 |
 |                             4 |                  4 |
 |-------------------------------+--------------------|
 |                         total |               8067 |

To avoid a misunderstanding: By "complex" I refer to a message that
looks like:

<single text plain>
<multipart>
  <single text plain>
  <single text html>
</multipart>
<single text plain>
<multipart>
  <single text plain>
  <single text html>
</multipart>
<single text plain>

And is considered to be just one document.

It just makes no sense to create such a nested message: If the
recipient requires html markup than send him html markup.  Why such a
nested message?

Moreover: Even if this message complies with the specs it is out of
their scope.

My impression is that current implementation of org-mail-htmlize mixes
up two completely different operations: /Creating/ a MIME message and
/displaying/ a MIME message.  Because it is assumed that a MIME message
as given above will be displayed as a single document or message.  And
this assumption cannot be based on the MIME specs of RFC2045-2049.

In RFC2046, p. 23 it is explicitely noted:

"Conspicuously missing from the 'multipart' type is a notion of
structured, related body parts."

The relationship of the message parts in the example above: "We are
parts of a single document" is not transmitted.  This information is
not present at the recipient's side and a MUA is not obliged to
display all parts at once to be MIME compliant (cf. RFC2049).

And back to the purpose: The whole idea of sending html markup arouse
because some recipients require html markup to properly display the
transmitted information.  To achive this sending the entire plain text
as html markup in a single multipart/alternative is sufficient.  There
is no reason for ripping the original document apart, requiring a
certain interpretation of MIME messages on the client side.

Rhetoric question: Isn't this mixing up of sending and displaying
the problem of users who willingly or unwillingly send html messages
only?  They implicitely assume that the message will be rendered in
the same way on the recipients side as it is rendered for them.  Or
users who send out MS Word documents, based on their personal
experience that everybody they know is capable of displaying .doc
files?

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-03-31 22:03                           ` Eric Schulte
@ 2010-04-02  7:04                             ` David Maus
  2010-04-02 23:01                               ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-04-02  7:04 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 4401 bytes --]

Eric Schulte wrote:
>>
>> Thinking functional this might be the first function of
>> org-mail-htmlize[1]: Create a html representation of message body if
>> necessary or appropriate.
>>

>Oh, so this would be a slightly different issue,

>So this function could be run *every* time an email is sent.  I agree
>that in those cases running on the entire message would be the right way
>to go.

Right, this would be nice for people who are obliged to send out html
messages.  If this is turned on org-mime should display the string
"HTML" in the mode line.  In the WL it's done this way:

,----
| (defun dmj/wl-send-html-message-draft-init ()
|   "Create buffer local settings for maybe sending html message."
|   (unless (boundp 'dmj/wl-send-html-message-toggled-p)
|     (setq dmj/wl-send-html-message-toggled-p nil))
|   (make-variable-buffer-local 'dmj/wl-send-html-message-toggled-p)
|   (add-to-list 'global-mode-string
|                '(:eval (if (eq major-mode 'wl-draft-mode)
|                            dmj/wl-send-html-message-toggled-p))))
`----

This function is hooked into mime-edit mode and set's a buffer local
variable that indicates "html message mode" and is displayed in the
mode line.

>>
>> 2/
>>
>> The second function: Attach external files that are referenced in the
>> message.  This might be useful even if you don't send out html
>> messages: All external files are stashed into a multipart/mixed
>> container along with a Content-Id: header field.
>>
>> Than all references are changed accordingly to point to the attached
>> files:
>>
>>   - for html use src/href with the cid: prefix
>>
>>   - for text: good question.  Maybe replace occurences of the file
>>     with a customizable string saying: "see attached file foo.bar".
>>

>I'm not sure I understand, I'm currently happy with my mail agent's
>method of attaching files to email, what else would this use of the
>function add aside from a new attachment syntax.

What I meant was: Suppose you write a document in Org with references
to external files (images etc.).  If finished you'd like this document
to a fellow by mail including all external files.  So this function
collects all these files, and maybe converts the message body to html,
fires up Gnus/WL with a new message and inserts something like

< #multipart type="alternate">
< #part type="text/plain"> ...plain text body...
< #part type="text/html"> ...html body...
< #/multipart>
< #multipart type="mixed">
< #part type="image/png"> image1.png
< #part type="image/png"> image2.png
  ...
< #/multipart>

That is: The original document including all external files -- and all
references in the original file are replaced by references to the
attachments.

Original
,----
| ...
| As you can see in [[file:figure1.png][Figure 1]], cats
| *are* the cutest animals on earth.
| ...
`----

"figure1.png" will be attached and the reference adjusted to the
attachment.

HTML
,----
| As you can see in <a href="cid:id-of-figure1.png" title="Figure 1">Figure 1</a>,
| cats <b>are</b> the cutest animals on earth.
`----

Plain

,----
| As you can see in Figure 1 (see attached file: figure1.png), cats
| *are* the cutest animals on earth.
`----

>> 4/
>>
>> Detecting the plain text body should not just stop on end of buffer
>> but also on the first occurence of a MIME delimiter: Maybe the user
>> already added a attachment.
>>

>Good point, one open question here is how to treat that mime border, I'm
>thinking it may be best to simply stash it in a

>#+BEGIN_HTML
>original mime content
>#+END_HTML

>block, so that it survives the Org-mode export unscathed, however maybe
>it's simpler just to end the html alternative part at the first mime
>border.

Yes, it is simpler.  Simply search for the end of the message body
with the condition: either eobp or MIME delimiter.

For example when in mml (line 92ff in org-mime.el):

,----
| (html-end (or (and region-p (region-end))
| 	      (if (not (re-search-forward "^<#part\\|^<#multipart" nil t))
| 		  (point-max)
|		;; one line up
| 		(end-of-line 0)
| 		(point))))
`----

With this you can even catch the signature that is separate by "--
\n".  If re-search-forward finds an attachment the body ends right
before.  Small glitch: This code assumes MIME delimiters start at the
beginning of a line ("^").

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-02  6:34                             ` David Maus
@ 2010-04-02 14:57                               ` Dan Davison
  2010-04-02 17:25                                 ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: Dan Davison @ 2010-04-02 14:57 UTC (permalink / raw)
  To: David Maus; +Cc: Vagn Johansen, emacs-orgmode


[...]

> It just makes no sense to create such a nested message: If the
> recipient requires html markup than send him html markup.  Why such a
> nested message?

Hi David,

What about if I'm sending an email containing some org-mode elements
like tables, and also some code. I want the reader to he able to see the
plain text structure of the tables, so that they know exactly what's
going on. But for the code, I would like those using webmail clients to
see nicely formatted, fontified code.

Is that a potential justification?

Dan

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-02 14:57                               ` Dan Davison
@ 2010-04-02 17:25                                 ` David Maus
  2010-04-02 21:10                                   ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-04-02 17:25 UTC (permalink / raw)
  To: Dan Davison; +Cc: Vagn Johansen, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2346 bytes --]

Dan Davison wrote:

>[...]

>> It just makes no sense to create such a nested message: If the
>> recipient requires html markup than send him html markup.  Why such a
>> nested message?

>Hi David,

>What about if I'm sending an email containing some org-mode elements
>like tables, and also some code. I want the reader to he able to see the
>plain text structure of the tables, so that they know exactly what's
>going on. But for the code, I would like those using webmail clients to
>see nicely formatted, fontified code.

>Is that a potential justification?

I cannot answer this question because the whole idea of sending just
some parts of the entire document is based on a horrible mistake:

> But for the code, I would like those using webmail clients to see
> nicely formatted, fontified code.

I understand this idea, but: MIME is about message transport, not
message display.  You want the message displayed in a certain way but

  You have little control over how the content is displayed on the
  recipients side.

To give an example: I've sent one of the "complex" MIME messages to a
mail account at GMX, a quite popular german mail hoster and opened it
in the web interface.

The message was constructed like this (using mml like markup):

< #part type="text/plain">
First MIME entity
< #multipart type="alternative">
< #part type="text/plain">
  Second in plain text
< #part type="text/html">
  <b>Second</b> in HTML
< /#multipart>
< #part type="text/plain">
  Third MIME entity.
< #part type="text/plain">
  Fourth in plain text
< #part type="text/html">
  <b>Fourth</b> in HTML
< /#multipart>

  - when I first opened the message I had to toggle the NoScript
    extension to allow iframes:

    http://s10.directupload.net/file/u/15851/wydtca3n_png.htm

  - after that the html was shown, but... totally messed up

    http://s10.directupload.net/file/u/15851/j43xqkjt_png.htm

  - and finally I chose "plain text" display

    http://s1.directupload.net/file/u/15851/plz64u4a_png.htm

    And the second and fourth part was silently dropped.

Sending a simple message with a plain text body followed by it's html
representation was displayed fine:

http://s10.directupload.net/file/u/15851/ojdn8pdl_png.htm

See what I mean?

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-02 17:25                                 ` David Maus
@ 2010-04-02 21:10                                   ` Eric Schulte
  2010-04-03  9:00                                     ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-02 21:10 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, Vagn Johansen, emacs-orgmode

Hi,

Given the current setup, sending messages with multiple multipart
sections is simply one optional way of using the `org-mime-htmlize'
function.  By default when `org-mime-htmlize' is called without an
active region the entire message body is encoded as a single MIME
multipart/alternative -- the simpler approach you advocate below.

That said, I'm not sure what you are arguing for.  Are you arguing that
the option to send multiple multipart/alternative sections be removed?
This is an option which could only be used intentionally, hopefully in
full knowledge the potential risks and drawbacks.

In my opinion it is bad design to go out of your way to remove choice
and functionality from a program.  Additionally I don't like the idea of
limiting the functionality of a tool to the level of the lowest common
denominator of it's peers.  That is not how progress is made.

Thanks -- Eric

David Maus <dmaus@ictsoc.de> writes:

> Dan Davison wrote:
>
>>[...]
>
>>> It just makes no sense to create such a nested message: If the
>>> recipient requires html markup than send him html markup.  Why such a
>>> nested message?
>
>>Hi David,
>
>>What about if I'm sending an email containing some org-mode elements
>>like tables, and also some code. I want the reader to he able to see the
>>plain text structure of the tables, so that they know exactly what's
>>going on. But for the code, I would like those using webmail clients to
>>see nicely formatted, fontified code.
>
>>Is that a potential justification?
>
> I cannot answer this question because the whole idea of sending just
> some parts of the entire document is based on a horrible mistake:
>
>> But for the code, I would like those using webmail clients to see
>> nicely formatted, fontified code.
>
> I understand this idea, but: MIME is about message transport, not
> message display.  You want the message displayed in a certain way but
>
>   You have little control over how the content is displayed on the
>   recipients side.
>
> To give an example: I've sent one of the "complex" MIME messages to a
> mail account at GMX, a quite popular german mail hoster and opened it
> in the web interface.
>
> The message was constructed like this (using mml like markup):
>
> < #part type="text/plain">
> First MIME entity
> < #multipart type="alternative">
> < #part type="text/plain">
>   Second in plain text
> < #part type="text/html">
>   <b>Second</b> in HTML
> < /#multipart>
> < #part type="text/plain">
>   Third MIME entity.
> < #part type="text/plain">
>   Fourth in plain text
> < #part type="text/html">
>   <b>Fourth</b> in HTML
> < /#multipart>
>
>   - when I first opened the message I had to toggle the NoScript
>     extension to allow iframes:
>
>     http://s10.directupload.net/file/u/15851/wydtca3n_png.htm
>
>   - after that the html was shown, but... totally messed up
>
>     http://s10.directupload.net/file/u/15851/j43xqkjt_png.htm
>
>   - and finally I chose "plain text" display
>
>     http://s1.directupload.net/file/u/15851/plz64u4a_png.htm
>
>     And the second and fourth part was silently dropped.
>
> Sending a simple message with a plain text body followed by it's html
> representation was displayed fine:
>
> http://s10.directupload.net/file/u/15851/ojdn8pdl_png.htm
>
> See what I mean?
>
>  -- David
>
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-04-02  7:04                             ` David Maus
@ 2010-04-02 23:01                               ` Eric Schulte
  2010-04-03  9:19                                 ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-02 23:01 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

> Eric Schulte wrote:
>>>
>>> Thinking functional this might be the first function of
>>> org-mail-htmlize[1]: Create a html representation of message body if
>>> necessary or appropriate.
>>>
>
>>Oh, so this would be a slightly different issue,
>
>>So this function could be run *every* time an email is sent.  I agree
>>that in those cases running on the entire message would be the right way
>>to go.
>
> Right, this would be nice for people who are obliged to send out html
> messages.  If this is turned on org-mime should display the string
> "HTML" in the mode line.  In the WL it's done this way:
>
> ,----
> | (defun dmj/wl-send-html-message-draft-init ()
> |   "Create buffer local settings for maybe sending html message."
> |   (unless (boundp 'dmj/wl-send-html-message-toggled-p)
> |     (setq dmj/wl-send-html-message-toggled-p nil))
> |   (make-variable-buffer-local 'dmj/wl-send-html-message-toggled-p)
> |   (add-to-list 'global-mode-string
> |                '(:eval (if (eq major-mode 'wl-draft-mode)
> |                            dmj/wl-send-html-message-toggled-p))))
> `----
>
> This function is hooked into mime-edit mode and set's a buffer local
> variable that indicates "html message mode" and is displayed in the
> mode line.
>

Another option here is to add a defadvice to the actual sending command
(C-c C-c in gnus) such that if the command is called with a prefix
argument, then `org-mime-htmlize' is run on the entire message before
mail delivery.  To me this seems like a simpler solution than the above.

>
>>>
>>> 2/
>>>
>>> The second function: Attach external files that are referenced in the
>>> message.  This might be useful even if you don't send out html
>>> messages: All external files are stashed into a multipart/mixed
>>> container along with a Content-Id: header field.
>>>
>>> Than all references are changed accordingly to point to the attached
>>> files:
>>>
>>>   - for html use src/href with the cid: prefix
>>>
>>>   - for text: good question.  Maybe replace occurences of the file
>>>     with a customizable string saying: "see attached file foo.bar".
>>>
>
>>I'm not sure I understand, I'm currently happy with my mail agent's
>>method of attaching files to email, what else would this use of the
>>function add aside from a new attachment syntax.
>
> What I meant was: Suppose you write a document in Org with references
> to external files (images etc.).  If finished you'd like this document
> to a fellow by mail including all external files.  So this function
> collects all these files, and maybe converts the message body to html,
> fires up Gnus/WL with a new message and inserts something like
>
> < #multipart type="alternate">
> < #part type="text/plain"> ...plain text body...
> < #part type="text/html"> ...html body...
> < #/multipart>
> < #multipart type="mixed">
> < #part type="image/png"> image1.png
> < #part type="image/png"> image2.png
>   ...
> < #/multipart>
>
> That is: The original document including all external files -- and all
> references in the original file are replaced by references to the
> attachments.
>

Ah, this sounds similar to the extension proposed by Dan and seconded by
a couple of others on the list.  It seems like the big question here is
how to convey all of the required mime information from the org-mode
buffer to the message body.

If I'm understanding correctly both you and Dan seem to be in favor of
exporting to mime and packaging up the raw mime information from the
org-mode buffer.  I'm leaning towards thinking that it may be easier to
simply bring the mail buffer to the org-mode file by saving it to a
temporary location alongside the org-mode file (so all links resolve).
It will probably take some experimentation to find out which approach is
more feasible/natural.

>
> Original
> ,----
> | ...
> | As you can see in [[file:figure1.png][Figure 1]], cats
> | *are* the cutest animals on earth.
> | ...
> `----
>
> "figure1.png" will be attached and the reference adjusted to the
> attachment.
>
> HTML
> ,----
> | As you can see in <a href="cid:id-of-figure1.png" title="Figure 1">Figure 1</a>,
> | cats <b>are</b> the cutest animals on earth.
> `----
>
> Plain
>
> ,----
> | As you can see in Figure 1 (see attached file: figure1.png), cats
> | *are* the cutest animals on earth.
> `----
>
>>> 4/
>>>
>>> Detecting the plain text body should not just stop on end of buffer
>>> but also on the first occurence of a MIME delimiter: Maybe the user
>>> already added a attachment.
>>>
>
>>Good point, one open question here is how to treat that mime border, I'm
>>thinking it may be best to simply stash it in a
>
>>#+BEGIN_HTML
>>original mime content
>>#+END_HTML
>
>>block, so that it survives the Org-mode export unscathed, however maybe
>>it's simpler just to end the html alternative part at the first mime
>>border.
>
> Yes, it is simpler.  Simply search for the end of the message body
> with the condition: either eobp or MIME delimiter.
>
> For example when in mml (line 92ff in org-mime.el):
>
> ,----
> | (html-end (or (and region-p (region-end))
> | 	      (if (not (re-search-forward "^<#part\\|^<#multipart" nil t))
> | 		  (point-max)
> |		;; one line up
> | 		(end-of-line 0)
> | 		(point))))
> `----
>
> With this you can even catch the signature that is separate by "--
> \n".  If re-search-forward finds an attachment the body ends right
> before.  Small glitch: This code assumes MIME delimiters start at the
> beginning of a line ("^").
>

Agreed, this approach is simpler to implement however if the other
approach works I think it may be easier to use.  Again this question may
have to be hammered out on the forge of trial and error.

Thanks for the feedback.  There is clearly some more work do be done on
this front, but it is sounding like it will be a useful product once
complete.

Am I right in assuming that the current version is now working for WL?

Best -- Eric

>
>  -- David
>
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-02 21:10                                   ` Eric Schulte
@ 2010-04-03  9:00                                     ` David Maus
  2010-04-03 12:03                                       ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-04-03  9:00 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, Vagn Johansen, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1750 bytes --]

Eric Schulte wrote:
>Hi,

>Given the current setup, sending messages with multiple multipart
>sections is simply one optional way of using the `org-mime-htmlize'
>function.  By default when `org-mime-htmlize' is called without an
>active region the entire message body is encoded as a single MIME
>multipart/alternative -- the simpler approach you advocate below.

>That said, I'm not sure what you are arguing for.  Are you arguing that
>the option to send multiple multipart/alternative sections be removed?

Yes I would remove it until some further investigations into the world
of MIME and MUAs.  It can be easily added later.

Why not create an example message and throw it against as much MUAs as
possible?  This will at least allow us to go further than our personal
experience: If the majority of tested MUAs displays the message as
intended, than fine -- provide this functionallity with a warning.

I've tested so far with a really simple one:

 | MUA                  | Display ok?                             |
 |----------------------+-----------------------------------------|
 | Thunderbird 2.x      | Yes, horizontal lines between the parts |
 | MS Outlook Express 6 | Yes, horizontal lines between the parts |
 | Google               | Yes                                     |
 | GMX                  | Kind of...                              |
 | Squirrelmail         | Yes                                     |
 | Wanderlust           | Yes                                     |
 |                      |                                         |

Should be on the list: mutt, Evolution, Mail.app, smartphone-thins,
Opera Mail...

 -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-04-02 23:01                               ` Eric Schulte
@ 2010-04-03  9:19                                 ` David Maus
  2010-04-04 17:52                                   ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-04-03  9:19 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 3579 bytes --]

Eric Schulte wrote:
>David Maus <dmaus@ictsoc.de> writes:

>> Eric Schulte wrote:
>>>>
>>>> Thinking functional this might be the first function of
>>>> org-mail-htmlize[1]: Create a html representation of message body if
>>>> necessary or appropriate.
>>>>
>>
>>>Oh, so this would be a slightly different issue,
>>
>>>So this function could be run *every* time an email is sent.  I agree
>>>that in those cases running on the entire message would be the right way
>>>to go.
>>
>> Right, this would be nice for people who are obliged to send out html
>> messages.  If this is turned on org-mime should display the string
>> "HTML" in the mode line.  In the WL it's done this way:
>>
>> ,----
>> | (defun dmj/wl-send-html-message-draft-init ()
>> |   "Create buffer local settings for maybe sending html message."
>> |   (unless (boundp 'dmj/wl-send-html-message-toggled-p)
>> |     (setq dmj/wl-send-html-message-toggled-p nil))
>> |   (make-variable-buffer-local 'dmj/wl-send-html-message-toggled-p)
>> |   (add-to-list 'global-mode-string
>> |                '(:eval (if (eq major-mode 'wl-draft-mode)
>> |                            dmj/wl-send-html-message-toggled-p))))
>> `----
>>
>> This function is hooked into mime-edit mode and set's a buffer local
>> variable that indicates "html message mode" and is displayed in the
>> mode line.
>>

>Another option here is to add a defadvice to the actual sending command
>(C-c C-c in gnus) such that if the command is called with a prefix
>argument, then `org-mime-htmlize' is run on the entire message before
>mail delivery.  To me this seems like a simpler solution than the above.

Yes, somehow we have to hook or defadvice before mml/semi translates
the message buffer to real MIME.  I'm not sure about the defadive: We
would change functioallity of the translating function globally.

>>
>> What I meant was: Suppose you write a document in Org with references
>> to external files (images etc.).  If finished you'd like this document
>> to a fellow by mail including all external files.  So this function
>> collects all these files, and maybe converts the message body to html,
>> fires up Gnus/WL with a new message and inserts something like
>>
>> < #multipart type="alternate">
>> < #part type="text/plain"> ...plain text body...
>> < #part type="text/html"> ...html body...
>> < #/multipart>
>> < #multipart type="mixed">
>> < #part type="image/png"> image1.png
>> < #part type="image/png"> image2.png
>>   ...
>> < #/multipart>
>>
>> That is: The original document including all external files -- and all
>> references in the original file are replaced by references to the
>> attachments.
>>

>If I'm understanding correctly both you and Dan seem to be in favor
>of exporting to mime and packaging up the raw mime information from
>the org-mode buffer. I'm leaning towards thinking that it may be
>easier to simply bring the mail buffer to the org-mode file by saving
>it to a temporary location alongside the org-mode file (so all links
>resolve).  It will probably take some experimentation to find out
>which approach is more feasible/natural.

Funny thing: It's basically the same operation, only difference is in
the original content's source:

    +------------+
    | Org buffer |--+
    +------------+  |    +------------+   +----------------+
                    +--->| MIME setup |-->| Message buffer |
+----------------+  |    +------------+   +----------------+
| Message buffer |--+
+----------------+

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-03  9:00                                     ` David Maus
@ 2010-04-03 12:03                                       ` David Maus
  2010-04-04  2:41                                         ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: David Maus @ 2010-04-03 12:03 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, Vagn Johansen, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1100 bytes --]

David Maus wrote:
>[1  <text/plain; US-ASCII (7bit)>]
>Eric Schulte wrote:
>>Hi,

>>Given the current setup, sending messages with multiple multipart
>>sections is simply one optional way of using the `org-mime-htmlize'
>>function.  By default when `org-mime-htmlize' is called without an
>>active region the entire message body is encoded as a single MIME
>>multipart/alternative -- the simpler approach you advocate below.

>>That said, I'm not sure what you are arguing for.  Are you arguing that
>>the option to send multiple multipart/alternative sections be removed?

>Yes I would remove it until some further investigations into the world
>of MIME and MUAs.  It can be easily added later.

Okay, gave it a thought and here is my uber argument:

Even if a MUA renders the entire message it will inevitably look ugly:
Because the characters in the pure text/plain section will be rendered
completely different than the characters in the html markup.  The
entire message will look inconsistent.

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-03 12:03                                       ` David Maus
@ 2010-04-04  2:41                                         ` Eric Schulte
  2010-04-04 10:00                                           ` David Maus
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-04  2:41 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, Vagn Johansen, emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

[...]

> Okay, gave it a thought and here is my uber argument:
>
> Even if a MUA renders the entire message it will inevitably look ugly:
> Because the characters in the pure text/plain section will be rendered
> completely different than the characters in the html markup.  The
> entire message will look inconsistent.
>

Alright, here are two final points summarizing my perspective.

1) Emacs is not about the paternalistic removal of potentially unsafe
   functionality.  Emacs is about giving users as much power and choice
   as possible, even if that amounts to given them enough rope to hang
   themselves.

2) I've used this functionality, seen the results, and I like it

We may have to agree to disagree on this one.

All the Best -- Eric

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: Re: using orgmode to send html mail?
  2010-04-04  2:41                                         ` Eric Schulte
@ 2010-04-04 10:00                                           ` David Maus
  0 siblings, 0 replies; 63+ messages in thread
From: David Maus @ 2010-04-04 10:00 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, Vagn Johansen, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 661 bytes --]

Eric Schulte wrote:

>Alright, here are two final points summarizing my perspective.

>1) Emacs is not about the paternalistic removal of potentially unsafe
>   functionality.  Emacs is about giving users as much power and choice
>   as possible, even if that amounts to given them enough rope to hang
>   themselves.

>2) I've used this functionality, seen the results, and I like it

Final question.  You wrote:

> Unless it actually becomes a problem I don't see any reason not to
> use the standard to it's full power.

What than qualifies as a "problem"?

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: using orgmode to send html mail?
  2010-04-03  9:19                                 ` David Maus
@ 2010-04-04 17:52                                   ` Eric Schulte
  0 siblings, 0 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-04 17:52 UTC (permalink / raw)
  To: David Maus; +Cc: Dan Davison, emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

> Eric Schulte wrote:
>>David Maus <dmaus@ictsoc.de> writes:
>
>>> Eric Schulte wrote:
>>>>>
>>>>> Thinking functional this might be the first function of
>>>>> org-mail-htmlize[1]: Create a html representation of message body if
>>>>> necessary or appropriate.
>>>>>
>>>
>>>>Oh, so this would be a slightly different issue,
>>>
>>>>So this function could be run *every* time an email is sent.  I agree
>>>>that in those cases running on the entire message would be the right way
>>>>to go.
>>>
>>> Right, this would be nice for people who are obliged to send out html
>>> messages.  If this is turned on org-mime should display the string
>>> "HTML" in the mode line.  In the WL it's done this way:
>>>
>>> ,----
>>> | (defun dmj/wl-send-html-message-draft-init ()
>>> |   "Create buffer local settings for maybe sending html message."
>>> |   (unless (boundp 'dmj/wl-send-html-message-toggled-p)
>>> |     (setq dmj/wl-send-html-message-toggled-p nil))
>>> |   (make-variable-buffer-local 'dmj/wl-send-html-message-toggled-p)
>>> |   (add-to-list 'global-mode-string
>>> |                '(:eval (if (eq major-mode 'wl-draft-mode)
>>> |                            dmj/wl-send-html-message-toggled-p))))
>>> `----
>>>
>>> This function is hooked into mime-edit mode and set's a buffer local
>>> variable that indicates "html message mode" and is displayed in the
>>> mode line.
>>>
>
>>Another option here is to add a defadvice to the actual sending command
>>(C-c C-c in gnus) such that if the command is called with a prefix
>>argument, then `org-mime-htmlize' is run on the entire message before
>>mail delivery.  To me this seems like a simpler solution than the above.
>
> Yes, somehow we have to hook or defadvice before mml/semi translates
> the message buffer to real MIME.  I'm not sure about the defadive: We
> would change functioallity of the translating function globally.
>

I've done this previously.  Luckily orgstruct-mode already intercepts
C-c C-c (which is used to send mail in gnus) and it is not difficult to
check for a prefix argument at that stage (before any mime encoding) and
optionally run an html conversion there.

>
>>>
>>> What I meant was: Suppose you write a document in Org with references
>>> to external files (images etc.).  If finished you'd like this document
>>> to a fellow by mail including all external files.  So this function
>>> collects all these files, and maybe converts the message body to html,
>>> fires up Gnus/WL with a new message and inserts something like
>>>
>>> < #multipart type="alternate">
>>> < #part type="text/plain"> ...plain text body...
>>> < #part type="text/html"> ...html body...
>>> < #/multipart>
>>> < #multipart type="mixed">
>>> < #part type="image/png"> image1.png
>>> < #part type="image/png"> image2.png
>>>   ...
>>> < #/multipart>
>>>
>>> That is: The original document including all external files -- and all
>>> references in the original file are replaced by references to the
>>> attachments.
>>>
>
>>If I'm understanding correctly both you and Dan seem to be in favor
>>of exporting to mime and packaging up the raw mime information from
>>the org-mode buffer. I'm leaning towards thinking that it may be
>>easier to simply bring the mail buffer to the org-mode file by saving
>>it to a temporary location alongside the org-mode file (so all links
>>resolve).  It will probably take some experimentation to find out
>>which approach is more feasible/natural.
>
> Funny thing: It's basically the same operation, only difference is in
> the original content's source:
>
>     +------------+
>     | Org buffer |--+
>     +------------+  |    +------------+   +----------------+
>                     +--->| MIME setup |-->| Message buffer |
> +----------------+  |    +------------+   +----------------+
> | Message buffer |--+
> +----------------+
>

Yup, I looks like it will just be a question of how to position the
resulting message buffer so that all of the references resolve.

Thanks -- Eric

>
>  -- David
>
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-04-01 14:22                                 ` Eric Schulte
@ 2010-04-05  5:39                                   ` Eric Schulte
  2010-04-05  6:49                                     ` Carsten Dominik
  2010-04-05 13:54                                     ` [CONTRIB?] " Dan Davison
  0 siblings, 2 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-05  5:39 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Hi,

It is now possible to send HTML mail directly form an org-mode buffer.

Calling `org-mime-org-buffer-htmlize' (could probably use a better name)
from inside of an org-mode buffer will use `org-export-as-html' to
generate HTML of the buffer (respecting regions and subtree narrowing),
and will then package the resulting HTML with all linked images into a
message buffer.

As usual thanks to Carsten's thoughtfully organized functions and
control variables this was surprisingly easy to implement.

Cheers -- Eric

The code is still up at http://github.com/eschulte/org-mime

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Dan Davison <davison@stats.ox.ac.uk> writes:
>
> [...]
>
>>
>> As I understand it the code you've written is designed to be called in a
>> message-mode buffer with orgstruct-mode in force. Would it make sense to
>> also include in your package a complementary function, that one calls in
>> an org-mode buffer? I envisage this generating the HTML, forming the
>> multipart email contents, and then saving it to the kill ring, so that
>> it can be pasted into an email.
>>
>> This function would have access to the directory-name and so should be
>> able to resolve relative paths. Also, there might be some other
>> advantages -- for example when exporting just a region or subtree,
>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up by the
>> org exporter and packaged into the HTML.
>>
>> In other words, can I use your machinery to package up the HTML
>> generated by Org's C-e dispatcher into an appropriately-constructed
>> email?
>>
>
> Hi Dan,
>
> That sounds like a good idea, I've added it to a fledgling task list
> packaged in the README at [1].  I'd say there are two options.
>
> 1) which you mentioned saving the entire exported content to the
>    kill-ring.  One problem here is that everything is still text and
>    pastable only *before* the mime export process, which means that
>    linked images wouldn't resolve after pasting into the email client.
>
> 2) having the function generate a new mail buffer containing the
>    exported content.  This buffer would need to have it's
>    `buffer-file-name' set, for images to resolve during export.  I'm not
>    sure how this should best work.
>
> Thanks -- Eric
>
> Footnotes: 
> [1]  http://github.com/eschulte/org-mime

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-04-05  5:39                                   ` Eric Schulte
@ 2010-04-05  6:49                                     ` Carsten Dominik
  2010-04-05 15:31                                       ` Eric Schulte
  2010-04-05 13:54                                     ` [CONTRIB?] " Dan Davison
  1 sibling, 1 reply; 63+ messages in thread
From: Carsten Dominik @ 2010-04-05  6:49 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Dan Davison, emacs-orgmode


On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:

> Hi,
>
> It is now possible to send HTML mail directly form an org-mode buffer.
>
> Calling `org-mime-org-buffer-htmlize' (could probably use a better  
> name)
> from inside of an org-mode buffer will use `org-export-as-html' to
> generate HTML of the buffer (respecting regions and subtree  
> narrowing),
> and will then package the resulting HTML with all linked images into a
> message buffer.
>
> As usual thanks to Carsten's thoughtfully organized functions and
> control variables this was surprisingly easy to implement.
>
> Cheers -- Eric
>
> The code is still up at http://github.com/eschulte/org-mime

CONTIRB?  yes, after the release.....

- Carsten

>
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Dan Davison <davison@stats.ox.ac.uk> writes:
>>
>> [...]
>>
>>>
>>> As I understand it the code you've written is designed to be  
>>> called in a
>>> message-mode buffer with orgstruct-mode in force. Would it make  
>>> sense to
>>> also include in your package a complementary function, that one  
>>> calls in
>>> an org-mode buffer? I envisage this generating the HTML, forming the
>>> multipart email contents, and then saving it to the kill ring, so  
>>> that
>>> it can be pasted into an email.
>>>
>>> This function would have access to the directory-name and so  
>>> should be
>>> able to resolve relative paths. Also, there might be some other
>>> advantages -- for example when exporting just a region or subtree,
>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up  
>>> by the
>>> org exporter and packaged into the HTML.
>>>
>>> In other words, can I use your machinery to package up the HTML
>>> generated by Org's C-e dispatcher into an appropriately-constructed
>>> email?
>>>
>>
>> Hi Dan,
>>
>> That sounds like a good idea, I've added it to a fledgling task list
>> packaged in the README at [1].  I'd say there are two options.
>>
>> 1) which you mentioned saving the entire exported content to the
>>   kill-ring.  One problem here is that everything is still text and
>>   pastable only *before* the mime export process, which means that
>>   linked images wouldn't resolve after pasting into the email client.
>>
>> 2) having the function generate a new mail buffer containing the
>>   exported content.  This buffer would need to have it's
>>   `buffer-file-name' set, for images to resolve during export.  I'm  
>> not
>>   sure how this should best work.
>>
>> Thanks -- Eric
>>
>> Footnotes:
>> [1]  http://github.com/eschulte/org-mime
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-04-05  5:39                                   ` Eric Schulte
  2010-04-05  6:49                                     ` Carsten Dominik
@ 2010-04-05 13:54                                     ` Dan Davison
  2010-04-05 14:50                                       ` David Maus
  2010-04-05 14:53                                       ` Dan Davison
  1 sibling, 2 replies; 63+ messages in thread
From: Dan Davison @ 2010-04-05 13:54 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 869 bytes --]

Hi Eric,

Thanks a lot for this, I think I'll use it quite a bit.

This may be specific to my setup, but in case this is useful to others,
as a gnus user I had to do

(setq mail-user-agent 'message-user-agent)

Without altering this --- i.e. with mail-user-agent set to the default
value of 'sendmail-user-agent --- org-mime-org-buffer-htmlize puts the
outgoing message in mail-mode (a.o.t. message-mode). For me, that meant
that the resulting outgoing email was rendered verbatim in gmail,
whereas from message-mode it is fine. The exact contents of outgoing
emails are below.

I noticed one small bug, but perhaps it's an org-mode bug? When I use
org-mime-org-buffer-htmlize on this

,----
| *** Tasks
|     - [ ] Check Popen.returncode of python system calls
`----

I get the following, which renders as a checkbox with an X, whereas my
checkbox was empty.

,----
| 

[-- Attachment #2.1: Type: text/plain, Size: 70 bytes --]

*** Tasks
|     - [ ] Check Popen.returncode of python system calls
| 

[-- Attachment #2.2: Type: text/html, Size: 136 bytes --]

[-- Attachment #3: Type: text/plain, Size: 419 bytes --]

`----

Comparison of outgoing mail from mail-mode and message-mode:

With an org buffer containing (as active region or not)

,----
| * heading
|   text
`----

Here is what the outgoing email (i.e. the stdin received by
sendmail-program) looks like from mail-mode (mail formed by
org-mime-org-buffer-htmlize)

--8<---------------cut here---------------start------------->8---
To: dandavison0@gmail.com
Subject: test16


[-- Attachment #4.1: Type: text/plain, Size: 17 bytes --]

* heading
  text

[-- Attachment #4.2: Type: text/html, Size: 146 bytes --]

[-- Attachment #5: Type: text/plain, Size: 3531 bytes --]

--8<---------------cut here---------------end--------------->8---


And here is what the outgoing email looks like from message-mode (exact
same content, but pasted from mail-mode into message-mode).

--8<---------------cut here---------------start------------->8---
From: Dan Davison <davison@stats.ox.ac.uk>
To: dandavison0@gmail.com
Subject: test16
Date: Mon, 05 Apr 2010 09:26:23 -0400
Message-ID: <87y6h2f2tc.fsf@stats.ox.ac.uk>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=-=-="

--=-=-=

* heading
  text

--=-=-=
Content-Type: text/html

<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">heading </h2>
<div class="outline-text-2" id="text-1">

<p>text
</p></div>
</div>

--=-=-=--
--8<---------------cut here---------------end--------------->8---

Dan

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Hi,
>
> It is now possible to send HTML mail directly form an org-mode buffer.
>
> Calling `org-mime-org-buffer-htmlize' (could probably use a better name)
> from inside of an org-mode buffer will use `org-export-as-html' to
> generate HTML of the buffer (respecting regions and subtree narrowing),
> and will then package the resulting HTML with all linked images into a
> message buffer.
>
> As usual thanks to Carsten's thoughtfully organized functions and
> control variables this was surprisingly easy to implement.
>
> Cheers -- Eric
>
> The code is still up at http://github.com/eschulte/org-mime
>
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Dan Davison <davison@stats.ox.ac.uk> writes:
>>
>> [...]
>>
>>>
>>> As I understand it the code you've written is designed to be called in a
>>> message-mode buffer with orgstruct-mode in force. Would it make sense to
>>> also include in your package a complementary function, that one calls in
>>> an org-mode buffer? I envisage this generating the HTML, forming the
>>> multipart email contents, and then saving it to the kill ring, so that
>>> it can be pasted into an email.
>>>
>>> This function would have access to the directory-name and so should be
>>> able to resolve relative paths. Also, there might be some other
>>> advantages -- for example when exporting just a region or subtree,
>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up by the
>>> org exporter and packaged into the HTML.
>>>
>>> In other words, can I use your machinery to package up the HTML
>>> generated by Org's C-e dispatcher into an appropriately-constructed
>>> email?
>>>
>>
>> Hi Dan,
>>
>> That sounds like a good idea, I've added it to a fledgling task list
>> packaged in the README at [1].  I'd say there are two options.
>>
>> 1) which you mentioned saving the entire exported content to the
>>    kill-ring.  One problem here is that everything is still text and
>>    pastable only *before* the mime export process, which means that
>>    linked images wouldn't resolve after pasting into the email client.
>>
>> 2) having the function generate a new mail buffer containing the
>>    exported content.  This buffer would need to have it's
>>    `buffer-file-name' set, for images to resolve during export.  I'm not
>>    sure how this should best work.
>>
>> Thanks -- Eric
>>
>> Footnotes: 
>> [1]  http://github.com/eschulte/org-mime
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

[-- Attachment #6: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-04-05 13:54                                     ` [CONTRIB?] " Dan Davison
@ 2010-04-05 14:50                                       ` David Maus
  2010-04-05 14:53                                       ` Dan Davison
  1 sibling, 0 replies; 63+ messages in thread
From: David Maus @ 2010-04-05 14:50 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1265 bytes --]

Dan Davison wrote:
>I noticed one small bug, but perhaps it's an org-mode bug? When I use
>org-mime-org-buffer-htmlize on this

>,----
>| *** Tasks
>|     - [ ] Check Popen.returncode of python system calls
>`----

>I get the following, which renders as a checkbox with an X, whereas my
>checkbox was empty.

>,----
>|
>[2  <multipart/alternative (7bit)>]
>[2.1  <text/plain (7bit)>]

>[2.2  <text/html (7bit)>]
>|

>    |
>  * | [X] Check Popen.returncode of python system calls
>    | |

>|

Welcome to my world.  A good example of what I pointed at:

  You have little control over how the content is displayed on the
  recipients side.

Whether the check box /appears/ to be ticked or empty depends on the
environment: For me, using w3m to render html back to plain text it is
ticked.  For me, using a web mail client it is not[1].

It depends on the HTML rendering engine and it's capabilities with
regards to render CSS.  In HTML export the check box contains the X
which is made invisible using a CSS definition.

Of course this problem applies not just to HTML messages but also to
websites.

 -- David

[1] http://s5.directupload.net/images/user/100405/2572mf8n.png

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-04-05 13:54                                     ` [CONTRIB?] " Dan Davison
  2010-04-05 14:50                                       ` David Maus
@ 2010-04-05 14:53                                       ` Dan Davison
  2010-04-05 15:30                                         ` Eric Schulte
  1 sibling, 1 reply; 63+ messages in thread
From: Dan Davison @ 2010-04-05 14:53 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

Hmm, perhaps I should have been a bit more careful with protecting the
various special email constructs in my message. Second try:

Dan Davison <davison@stats.ox.ac.uk> writes:

> Hi Eric,
>
> Thanks a lot for this, I think I'll use it quite a bit.
>
> This may be specific to my setup, but in case this is useful to others,
> as a gnus user I had to do
>
> (setq mail-user-agent 'message-user-agent)
>
> Without altering this --- i.e. with mail-user-agent set to the default
> value of 'sendmail-user-agent --- org-mime-org-buffer-htmlize puts the
> outgoing message in mail-mode (a.o.t. message-mode). For me, that meant
> that the resulting outgoing email was rendered verbatim in gmail,
> whereas from message-mode it is fine. The exact contents of outgoing
> emails are below.
>
> I noticed one small bug, but perhaps it's an org-mode bug? When I use
> org-mime-org-buffer-htmlize on this
>
> ,----
> | *** Tasks
> |     - [ ] Check Popen.returncode of python system calls
> `----
>
> I get the following, which renders as a checkbox with an X, whereas my
> checkbox was empty.

(I've replaced the <> tag delimiters with {})

--8<---------------cut here---------------start------------->8---
{#multipart type=alternative}{#part type=text/plain}

*** Tasks
    - [ ] Check Popen.returncode of python system calls
{#part type=text/html}{div id="outline-container-1" class="outline-3"}
{h3 id="sec-1"}Tasks {/h3}
{div class="outline-text-3" id="text-1"}

{ul}
{li}
{b}[{span style="visibility:hidden;"}X{/span}]{/b} Check Popen.returncode of python system calls
{/li}
{/ul}
{/div}
{/div}
{#/multipart}
--8<---------------cut here---------------end--------------->8---

> Comparison of outgoing mail from mail-mode and message-mode:
>
> With an org buffer containing (as active region or not)
>
> ,----
> | * heading
> |   text
> `----
>
> Here is what the outgoing email (i.e. the stdin received by
> sendmail-program) looks like from mail-mode (mail formed by
> org-mime-org-buffer-htmlize)
>

--8<---------------cut here---------------start------------->8---
To: dandavison0@gmail.com
Subject: test

{#multipart type=alternative}{#part type=text/plain}
* heading
  text{#part type=text/html}{div id="outline-container-1" class="outline-2"}
{h2 id="sec-1"}heading {/h2}
{div class="outline-text-2" id="text-1"}

{p}text
{/p}{/div}
{/div}
{#/multipart}
--8<---------------cut here---------------end--------------->8---

> And here is what the outgoing email looks like from message-mode (exact
> same content, but pasted from mail-mode into message-mode).
>

> --8<---------------cut here---------------start------------->8---
> From: Dan Davison <davison@stats.ox.ac.uk>
> To: dandavison0@gmail.com
> Subject: test16
> Date: Mon, 05 Apr 2010 09:26:23 -0400
> Message-ID: <87y6h2f2tc.fsf@stats.ox.ac.uk>
> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
> MIME-Version: 1.0
> Content-Type: multipart/alternative; boundary="=-=-="
>
> --=-=-=
>
> * heading
>   text
>
> --=-=-=
> Content-Type: text/html
>
> <div id="outline-container-1" class="outline-2">
> <h2 id="sec-1">heading </h2>
> <div class="outline-text-2" id="text-1">
>
> <p>text
> </p></div>
> </div>
>
> --=-=-=--
> --8<---------------cut here---------------end--------------->8---
>
> Dan
>
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Hi,
>>
>> It is now possible to send HTML mail directly form an org-mode buffer.
>>
>> Calling `org-mime-org-buffer-htmlize' (could probably use a better name)
>> from inside of an org-mode buffer will use `org-export-as-html' to
>> generate HTML of the buffer (respecting regions and subtree narrowing),
>> and will then package the resulting HTML with all linked images into a
>> message buffer.
>>
>> As usual thanks to Carsten's thoughtfully organized functions and
>> control variables this was surprisingly easy to implement.
>>
>> Cheers -- Eric
>>
>> The code is still up at http://github.com/eschulte/org-mime
>>
>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>
>>> Dan Davison <davison@stats.ox.ac.uk> writes:
>>>
>>> [...]
>>>
>>>>
>>>> As I understand it the code you've written is designed to be called in a
>>>> message-mode buffer with orgstruct-mode in force. Would it make sense to
>>>> also include in your package a complementary function, that one calls in
>>>> an org-mode buffer? I envisage this generating the HTML, forming the
>>>> multipart email contents, and then saving it to the kill ring, so that
>>>> it can be pasted into an email.
>>>>
>>>> This function would have access to the directory-name and so should be
>>>> able to resolve relative paths. Also, there might be some other
>>>> advantages -- for example when exporting just a region or subtree,
>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up by the
>>>> org exporter and packaged into the HTML.
>>>>
>>>> In other words, can I use your machinery to package up the HTML
>>>> generated by Org's C-e dispatcher into an appropriately-constructed
>>>> email?
>>>>
>>>
>>> Hi Dan,
>>>
>>> That sounds like a good idea, I've added it to a fledgling task list
>>> packaged in the README at [1].  I'd say there are two options.
>>>
>>> 1) which you mentioned saving the entire exported content to the
>>>    kill-ring.  One problem here is that everything is still text and
>>>    pastable only *before* the mime export process, which means that
>>>    linked images wouldn't resolve after pasting into the email client.
>>>
>>> 2) having the function generate a new mail buffer containing the
>>>    exported content.  This buffer would need to have it's
>>>    `buffer-file-name' set, for images to resolve during export.  I'm not
>>>    sure how this should best work.
>>>
>>> Thanks -- Eric
>>>
>>> Footnotes: 
>>> [1]  http://github.com/eschulte/org-mime
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please 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] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-04-05 14:53                                       ` Dan Davison
@ 2010-04-05 15:30                                         ` Eric Schulte
  0 siblings, 0 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-05 15:30 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

It's certainly true that email clients can be particular about how they
display HTML.

One possible fix for issues like these is to use the
`org-mime-html-hook' hook and the `org-mime-change-element-style'
function for forcing inline css into the misbehaving elements.

Best -- Eric

Dan Davison <davison@stats.ox.ac.uk> writes:

> Hmm, perhaps I should have been a bit more careful with protecting the
> various special email constructs in my message. Second try:
>
> Dan Davison <davison@stats.ox.ac.uk> writes:
>
>> Hi Eric,
>>
>> Thanks a lot for this, I think I'll use it quite a bit.
>>
>> This may be specific to my setup, but in case this is useful to others,
>> as a gnus user I had to do
>>
>> (setq mail-user-agent 'message-user-agent)
>>
>> Without altering this --- i.e. with mail-user-agent set to the default
>> value of 'sendmail-user-agent --- org-mime-org-buffer-htmlize puts the
>> outgoing message in mail-mode (a.o.t. message-mode). For me, that meant
>> that the resulting outgoing email was rendered verbatim in gmail,
>> whereas from message-mode it is fine. The exact contents of outgoing
>> emails are below.
>>
>> I noticed one small bug, but perhaps it's an org-mode bug? When I use
>> org-mime-org-buffer-htmlize on this
>>
>> ,----
>> | *** Tasks
>> |     - [ ] Check Popen.returncode of python system calls
>> `----
>>
>> I get the following, which renders as a checkbox with an X, whereas my
>> checkbox was empty.
>
> (I've replaced the <> tag delimiters with {})
>
> {#multipart type=alternative}{#part type=text/plain}
>
> *** Tasks
>     - [ ] Check Popen.returncode of python system calls
> {#part type=text/html}{div id="outline-container-1" class="outline-3"}
> {h3 id="sec-1"}Tasks {/h3}
> {div class="outline-text-3" id="text-1"}
>
> {ul}
> {li}
> {b}[{span style="visibility:hidden;"}X{/span}]{/b} Check Popen.returncode of python system calls
> {/li}
> {/ul}
> {/div}
> {/div}
> {#/multipart}
>
>> Comparison of outgoing mail from mail-mode and message-mode:
>>
>> With an org buffer containing (as active region or not)
>>
>> ,----
>> | * heading
>> |   text
>> `----
>>
>> Here is what the outgoing email (i.e. the stdin received by
>> sendmail-program) looks like from mail-mode (mail formed by
>> org-mime-org-buffer-htmlize)
>>
>
> To: dandavison0@gmail.com
> Subject: test
>
> {#multipart type=alternative}{#part type=text/plain}
> * heading
>   text{#part type=text/html}{div id="outline-container-1" class="outline-2"}
> {h2 id="sec-1"}heading {/h2}
> {div class="outline-text-2" id="text-1"}
>
> {p}text
> {/p}{/div}
> {/div}
> {#/multipart}
>
>> And here is what the outgoing email looks like from message-mode (exact
>> same content, but pasted from mail-mode into message-mode).
>>
>
>> --8<---------------cut here---------------start------------->8---
>> From: Dan Davison <davison@stats.ox.ac.uk>
>> To: dandavison0@gmail.com
>> Subject: test16
>> Date: Mon, 05 Apr 2010 09:26:23 -0400
>> Message-ID: <87y6h2f2tc.fsf@stats.ox.ac.uk>
>> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
>> MIME-Version: 1.0
>> Content-Type: multipart/alternative; boundary="=-=-="
>>
>> --=-=-=
>>
>> * heading
>>   text
>>
>> --=-=-=
>> Content-Type: text/html
>>
>> <div id="outline-container-1" class="outline-2">
>> <h2 id="sec-1">heading </h2>
>> <div class="outline-text-2" id="text-1">
>>
>> <p>text
>> </p></div>
>> </div>
>>
>> --=-=-=--
>> --8<---------------cut here---------------end--------------->8---
>>
>> Dan
>>
>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>
>>> Hi,
>>>
>>> It is now possible to send HTML mail directly form an org-mode buffer.
>>>
>>> Calling `org-mime-org-buffer-htmlize' (could probably use a better name)
>>> from inside of an org-mode buffer will use `org-export-as-html' to
>>> generate HTML of the buffer (respecting regions and subtree narrowing),
>>> and will then package the resulting HTML with all linked images into a
>>> message buffer.
>>>
>>> As usual thanks to Carsten's thoughtfully organized functions and
>>> control variables this was surprisingly easy to implement.
>>>
>>> Cheers -- Eric
>>>
>>> The code is still up at http://github.com/eschulte/org-mime
>>>
>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>
>>>> Dan Davison <davison@stats.ox.ac.uk> writes:
>>>>
>>>> [...]
>>>>
>>>>>
>>>>> As I understand it the code you've written is designed to be called in a
>>>>> message-mode buffer with orgstruct-mode in force. Would it make sense to
>>>>> also include in your package a complementary function, that one calls in
>>>>> an org-mode buffer? I envisage this generating the HTML, forming the
>>>>> multipart email contents, and then saving it to the kill ring, so that
>>>>> it can be pasted into an email.
>>>>>
>>>>> This function would have access to the directory-name and so should be
>>>>> able to resolve relative paths. Also, there might be some other
>>>>> advantages -- for example when exporting just a region or subtree,
>>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up by the
>>>>> org exporter and packaged into the HTML.
>>>>>
>>>>> In other words, can I use your machinery to package up the HTML
>>>>> generated by Org's C-e dispatcher into an appropriately-constructed
>>>>> email?
>>>>>
>>>>
>>>> Hi Dan,
>>>>
>>>> That sounds like a good idea, I've added it to a fledgling task list
>>>> packaged in the README at [1].  I'd say there are two options.
>>>>
>>>> 1) which you mentioned saving the entire exported content to the
>>>>    kill-ring.  One problem here is that everything is still text and
>>>>    pastable only *before* the mime export process, which means that
>>>>    linked images wouldn't resolve after pasting into the email client.
>>>>
>>>> 2) having the function generate a new mail buffer containing the
>>>>    exported content.  This buffer would need to have it's
>>>>    `buffer-file-name' set, for images to resolve during export.  I'm not
>>>>    sure how this should best work.
>>>>
>>>> Thanks -- Eric
>>>>
>>>> Footnotes: 
>>>> [1]  http://github.com/eschulte/org-mime
>>>
>>>
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Please 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] 63+ messages in thread

* Re: [CONTRIB?] using orgmode to send html mail?
  2010-04-05  6:49                                     ` Carsten Dominik
@ 2010-04-05 15:31                                       ` Eric Schulte
  2010-04-09 16:41                                         ` [ANN] org-mime -- " Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-05 15:31 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Dan Davison, emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
>
>> Hi,
>>
>> It is now possible to send HTML mail directly form an org-mode buffer.
>>
>> Calling `org-mime-org-buffer-htmlize' (could probably use a better
>> name)
>> from inside of an org-mode buffer will use `org-export-as-html' to
>> generate HTML of the buffer (respecting regions and subtree
>> narrowing),
>> and will then package the resulting HTML with all linked images into a
>> message buffer.
>>
>> As usual thanks to Carsten's thoughtfully organized functions and
>> control variables this was surprisingly easy to implement.
>>
>> Cheers -- Eric
>>
>> The code is still up at http://github.com/eschulte/org-mime
>
> CONTIRB?  yes, after the release.....
>

Sounds great, I'm move this into contrib then. -- Eric

>
> - Carsten
>
>>
>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>
>>> Dan Davison <davison@stats.ox.ac.uk> writes:
>>>
>>> [...]
>>>
>>>>
>>>> As I understand it the code you've written is designed to be
>>>> called in a
>>>> message-mode buffer with orgstruct-mode in force. Would it make
>>>> sense to
>>>> also include in your package a complementary function, that one
>>>> calls in
>>>> an org-mode buffer? I envisage this generating the HTML, forming the
>>>> multipart email contents, and then saving it to the kill ring, so
>>>> that
>>>> it can be pasted into an email.
>>>>
>>>> This function would have access to the directory-name and so
>>>> should be
>>>> able to resolve relative paths. Also, there might be some other
>>>> advantages -- for example when exporting just a region or subtree,
>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up
>>>> by the
>>>> org exporter and packaged into the HTML.
>>>>
>>>> In other words, can I use your machinery to package up the HTML
>>>> generated by Org's C-e dispatcher into an appropriately-constructed
>>>> email?
>>>>
>>>
>>> Hi Dan,
>>>
>>> That sounds like a good idea, I've added it to a fledgling task list
>>> packaged in the README at [1].  I'd say there are two options.
>>>
>>> 1) which you mentioned saving the entire exported content to the
>>>   kill-ring.  One problem here is that everything is still text and
>>>   pastable only *before* the mime export process, which means that
>>>   linked images wouldn't resolve after pasting into the email client.
>>>
>>> 2) having the function generate a new mail buffer containing the
>>>   exported content.  This buffer would need to have it's
>>>   `buffer-file-name' set, for images to resolve during export.  I'm
>>> not
>>>   sure how this should best work.
>>>
>>> Thanks -- Eric
>>>
>>> Footnotes:
>>> [1]  http://github.com/eschulte/org-mime
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
> - Carsten

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-05 15:31                                       ` Eric Schulte
@ 2010-04-09 16:41                                         ` Eric Schulte
  2010-04-09 17:41                                           ` Matt Price
                                                             ` (2 more replies)
  0 siblings, 3 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-09 16:41 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 133 bytes --]

Announcing the addition of org-mime to the contrib directory of Org-mode

this allows sending HTML email using org-mode including...

[-- Attachment #2.1: Type: text/plain, Size: 944 bytes --]

#+TITLE: NONE
#+OPTIONS: latex:t
- *tables*
  | colname one | colname two |
  |-------------+-------------|
  |           1 |           1 |
  |           2 |           4 |
  |           3 |           9 | 

- *inline images* including latex equations $f(n) = n + \frac{1}{n}
  \int_{0}^{n}{d_x f(x) + f(n - x)}$ and the results of ditaa blocks,
  etc...

  #+begin_src ditaa :file blue.png :cmdline -r
  +---------+
  | cBLU    |
  |         |
  |    +----+
  |    |cPNK|
  |    |    |
  +----+----+
  #+end_src

- *blockquotes*
  #+begin_quote
    HTML e-mail is the use of a subset of HTML (often ill-defined) to
    provide formatting and semantic markup capabilities in e-mail that
    are not available with plain text. -- wikipedia
  #+end_quote

- fontified *code blocks* (shown below)

- and *HTML character* conversion, like \forall character c s.t. \exists
  h \in /HTML characters/ and c \equiv h, org-html-export of c results
  in h

[-- Attachment #2.2: Type: text/html, Size: 1274 bytes --]

[-- Attachment #3: blue.png --]
[-- Type: image/png, Size: 2087 bytes --]

[-- Attachment #4: mail78058-A_b023893fa20418a1525cad63accc444e9a8954d3.png --]
[-- Type: image/png, Size: 2165 bytes --]

[-- Attachment #5: Type: text/plain, Size: 261 bytes --]


The original org-mode formatted plain text is included as a text/plain
mime alternative to the generated html.

Below find the org-mime export of the org-mime worg page which will be
available at http://orgmode.org/worg/org-contrib/org-mime.php.

Best -- Eric

[-- Attachment #6.1: Type: text/plain, Size: 3971 bytes --]

#+TITLE:     org-mime.el --- org html export for text/html MIME emails
#+OPTIONS:    H:3 num:nil toc:3 \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
#+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate
#+SEQ_TODO:   TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
#+TAGS:       Write(w) Update(u) Fix(f) Check(c) 
#+AUTHOR:     Eric Schulte
#+EMAIL:      schulte.eric at gmail dot com
#+LANGUAGE:   en
#+PRIORITIES: A C B
#+CATEGORY:   worg

* General

=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.

* How to use it

** Setup
=org-mime= exposes two functions

- `org-mime-htmlize' :: can be called from within a mail composition
     buffer to export either the entire buffer or just the active
     region to html, and embed the results into the buffer as a
     text/html mime section.
     : 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' :: can be called from within an
     Org-mode buffer to export either the whole buffer or the narrowed
     subtree or active region to HTML, and open a new email buffer
     including the resulting HTML content as an embedded mime section.
     : 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.
#+begin_src emacs-lisp
  (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)))
#+end_src

** CSS style customization
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.

- for those who use color themes with Dark backgrounds it is useful to
  set a dark background for all exported code blocks and example
  regions.  This can be accomplished with the following
  #+begin_src emacs-lisp
    (add-hook 'org-mime-html-hook
              (lambda ()
                (org-mime-change-element-style
                 "pre" (format "color: %s; background-color: %s; padding: 0.5em;"
                               "#E6E1DC" "#232323"))))
  #+end_src
- the following can be used to nicely offset block quotes in email
  bodies
  #+begin_src emacs-lisp
    (add-hook 'org-mime-html-hook
              (lambda ()
                (org-mime-change-element-style
                 "blockquote" "border-left: 2px solid gray; padding-left: 4px;")))    
  #+end_src

For other customization options see the =org-mime= customization
group.

* Credits

=org-mime= was developed by Eric Schulte with much-appreciated help
and discussion from everyone on the "[[http://thread.gmane.org/gmane.emacs.orgmode/23153][using orgmode to send html mail]]"
thread especially David Maus.

[-- Attachment #6.2: Type: text/html, Size: 5771 bytes --]

[-- Attachment #7: Type: text/plain, Size: 3108 bytes --]

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
>>
>>> Hi,
>>>
>>> It is now possible to send HTML mail directly form an org-mode buffer.
>>>
>>> Calling `org-mime-org-buffer-htmlize' (could probably use a better
>>> name)
>>> from inside of an org-mode buffer will use `org-export-as-html' to
>>> generate HTML of the buffer (respecting regions and subtree
>>> narrowing),
>>> and will then package the resulting HTML with all linked images into a
>>> message buffer.
>>>
>>> As usual thanks to Carsten's thoughtfully organized functions and
>>> control variables this was surprisingly easy to implement.
>>>
>>> Cheers -- Eric
>>>
>>> The code is still up at http://github.com/eschulte/org-mime
>>
>> CONTIRB?  yes, after the release.....
>>
>
> Sounds great, I'm move this into contrib then. -- Eric
>
>>
>> - Carsten
>>
>>>
>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>
>>>> Dan Davison <davison@stats.ox.ac.uk> writes:
>>>>
>>>> [...]
>>>>
>>>>>
>>>>> As I understand it the code you've written is designed to be
>>>>> called in a
>>>>> message-mode buffer with orgstruct-mode in force. Would it make
>>>>> sense to
>>>>> also include in your package a complementary function, that one
>>>>> calls in
>>>>> an org-mode buffer? I envisage this generating the HTML, forming the
>>>>> multipart email contents, and then saving it to the kill ring, so
>>>>> that
>>>>> it can be pasted into an email.
>>>>>
>>>>> This function would have access to the directory-name and so
>>>>> should be
>>>>> able to resolve relative paths. Also, there might be some other
>>>>> advantages -- for example when exporting just a region or subtree,
>>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up
>>>>> by the
>>>>> org exporter and packaged into the HTML.
>>>>>
>>>>> In other words, can I use your machinery to package up the HTML
>>>>> generated by Org's C-e dispatcher into an appropriately-constructed
>>>>> email?
>>>>>
>>>>
>>>> Hi Dan,
>>>>
>>>> That sounds like a good idea, I've added it to a fledgling task list
>>>> packaged in the README at [1].  I'd say there are two options.
>>>>
>>>> 1) which you mentioned saving the entire exported content to the
>>>>   kill-ring.  One problem here is that everything is still text and
>>>>   pastable only *before* the mime export process, which means that
>>>>   linked images wouldn't resolve after pasting into the email client.
>>>>
>>>> 2) having the function generate a new mail buffer containing the
>>>>   exported content.  This buffer would need to have it's
>>>>   `buffer-file-name' set, for images to resolve during export.  I'm
>>>> not
>>>>   sure how this should best work.
>>>>
>>>> Thanks -- Eric
>>>>
>>>> Footnotes:
>>>> [1]  http://github.com/eschulte/org-mime
>>>
>>>
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Please use `Reply All' to send replies to the list.
>>> Emacs-orgmode@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>
>> - Carsten

[-- Attachment #8: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-09 16:41                                         ` [ANN] org-mime -- " Eric Schulte
@ 2010-04-09 17:41                                           ` Matt Price
  2010-04-09 19:11                                             ` Eric Schulte
  2010-04-09 19:22                                             ` David Maus
  2010-04-12 13:37                                           ` Andrew Hyatt
  2010-04-13 23:03                                           ` Eric S Fraga
  2 siblings, 2 replies; 63+ messages in thread
From: Matt Price @ 2010-04-09 17:41 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1873 bytes --]

eric, this looks great --
On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com>wrote:

>
>   Setup
>
> org-mime exposes two functions
>  `org-mime-htmlize' can be called from within a mail composition buffer to
> export either the entire buffer or just the active region to html, and embed
> the results into the buffer as a text/html mime section.
>
> 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' can be called from within an Org-mode
> buffer to export either the whole buffer or the narrowed subtree or active
> region to HTML, and open a new email buffer including the resulting HTML
> content as an embedded mime section.
>
> 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)))
>
>
Just quickly -- so if I'm using wanderlust, will the resultant message still
be properly formatted?  I remember there was some discussion about the
separation syntax in different mailers but don'tremember how it turned out.
thanks for this -- man, does it look good in html!

matt

[-- Attachment #1.2: Type: text/html, Size: 3372 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-09 17:41                                           ` Matt Price
@ 2010-04-09 19:11                                             ` Eric Schulte
  2010-04-09 19:22                                             ` David Maus
  1 sibling, 0 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-09 19:11 UTC (permalink / raw)
  To: Matt Price; +Cc: emacs-orgmode

Matt Price <moptop99@gmail.com> writes:

> eric, this looks great --

Thanks

> Just quickly -- so if I'm using wanderlust, will the resultant message still
> be properly formatted?  I remember there was some discussion about the
> separation syntax in different mailers but don'tremember how it turned out.
> thanks for this -- man, does it look good in html!
>

Wanderlust should be supported, however there is not yet any VM
integration.  It should be easy to adjust the `org-mime-file' and
`org-mime-multipart' functions to add VM support.

Best -- Eric

>
> matt
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-09 17:41                                           ` Matt Price
  2010-04-09 19:11                                             ` Eric Schulte
@ 2010-04-09 19:22                                             ` David Maus
  2010-04-09 20:34                                               ` Eric Schulte
  1 sibling, 1 reply; 63+ messages in thread
From: David Maus @ 2010-04-09 19:22 UTC (permalink / raw)
  To: Matt Price; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1381 bytes --]

Matt Price wrote:

>Just quickly -- so if I'm using wanderlust, will the resultant
>message still be properly formatted?

This depends *entirely on recipients environment*.  May be, may be
not.  Maybe the parts are displayed, maybe they are not:

http://s1.directupload.net/images/user/100402/plz64u4a.png
(second and fourth part NOT displayed)

Parts of the mail will be rendered as plain text, others as html.
Maybe different font sizes and shapes (plain text vs. html markup).
Maybe the recipient cannot display images at all.  Maybe recipient's
mail program explodes: Heck, there weren't even tests to see how
mailers other than Google webmail, GMX webmail (see above!), Gnus,
Wanderlust, Thunderbird and Outlook Express 6 cope with these
messages.

Just consider this: Messaging might be WYSIWYG

What *you* see is what *you* get

But not WYSIWRG

What *you* see is what *recipient* gets.

When communication with others it's all about WRGIWYM

What *recipient* gets is what *you* meant.

@Erik:

> Emacs is about giving users as much power and choice as possible,
> even if that amounts to given them enough rope to hang themselves.

Then please at least /tell/ users of org-mime that they might break
their necks while just using org-mime to bundle message parts
together.

 -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-09 19:22                                             ` David Maus
@ 2010-04-09 20:34                                               ` Eric Schulte
  0 siblings, 0 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-09 20:34 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

> Matt Price wrote:
>
>>Just quickly -- so if I'm using wanderlust, will the resultant
>>message still be properly formatted?
>

I think the question was if wanderlust mime encoding works correctly.  I
believe the answer here is yes, but I do not have a wanderlust install
and can't personally verify.

>

[...]

> @Erik:
>
>> Emacs is about giving users as much power and choice as possible,
>> even if that amounts to given them enough rope to hang themselves.
>
> Then please at least /tell/ users of org-mime that they might break
> their necks while just using org-mime to bundle message parts
> together.
>

I'll put a warning up on the org-mime page on Worg.  But again,
personally I don't think this is a big deal.

Best -- Eric

>
>  -- David
>
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-09 16:41                                         ` [ANN] org-mime -- " Eric Schulte
  2010-04-09 17:41                                           ` Matt Price
@ 2010-04-12 13:37                                           ` Andrew Hyatt
  2010-04-12 17:22                                             ` Eric Schulte
  2010-04-13 23:03                                           ` Eric S Fraga
  2 siblings, 1 reply; 63+ messages in thread
From: Andrew Hyatt @ 2010-04-12 13:37 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 10741 bytes --]

This looks great.  However, I get an error on my test mail:

This is should be HTML mode.

~foo~
=bar=
_baz_

| Table | A |
| 1     | 2 |

On calling org-mime-htmlize

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match(nil #("This is should be HTML mode." 0 28 (fontified t)))
  byte-code("\304\211\x18\x19\305\n\v\"\203A
  org-html-handle-time-stamps(#("This is should be HTML mode." 0 28
(fontified t)))
  byte-code("\b\203\x13
  org-export-as-html(nil nil nil string t)
  (let nil (org-export-as-html nil nil nil (quote string) t))
  eval((let nil (org-export-as-html nil nil nil (quote string) t)))
  (progn (insert org-mime-default-header) (insert body) (write-file
tmp-file) (eval (list ... org-local-vars ...)))
  (unwind-protect (progn (insert org-mime-default-header) (insert body)
(write-file tmp-file) (eval ...)) (and (buffer-name temp-buffer)
(kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...
... ... ...) (and ... ...)))
  (with-current-buffer temp-buffer (unwind-protect (progn ... ... ... ...)
(and ... ...)))
  (let ((temp-buffer ...)) (with-current-buffer temp-buffer (unwind-protect
... ...)))
  (with-temp-buffer (insert org-mime-default-header) (insert body)
(write-file tmp-file) (eval (list ... org-local-vars ...)))
  (save-excursion (with-temp-buffer (insert org-mime-default-header) (insert
body) (write-file tmp-file) (eval ...)))
  org-mime-org-export("html" #("\nThis is should be HTML
mode.\n\n~foo~\n=bar=\n_baz_\n\n| Table | A |\n| 1     | 2 | \n\n-- \n" 0 1
(fontified t) 1 42 (fontified t) 42 43 (fontified t) 43 44 (article-type
emphasis fontified t) 44 47 (fontified t) 47 48 (article-type emphasis
fontified t) 48 50 (fontified t) 50 63 (fontified t face (gnus-cite-1
message-cited-text)) 63 64 (fontified t) 64 78 (fontified t face
(gnus-cite-1 message-cited-text)) 78 79 (fontified t rear-nonsticky t) 79 80
(fontified t) 80 84 (fontified t)) "/tmp/mail2522NRw")
  (org-mime-replace-images (org-mime-org-export "html" raw-body tmp-file)
tmp-file)
  (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
(tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
(org-export-htmlize-output-type ...) (org-export-preserve-breaks
org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
...)) (delete-region html-start html-end) (save-excursion (goto-char
html-start) (insert ... ...)))
  org-mime-htmlize(nil)


On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com>wrote:

> Announcing the addition of org-mime to the contrib directory of Org-mode
>
> this allows sending HTML email using org-mode including...
>
>
>    - *tables*   colname onecolname two  11 24 39
>    - *inline images* including latex equations [image: $f(n) = n +
>    \frac{1}{n} \int_{0}^{n}{d_x f(x) + f(n - x)}$] and the results of
>    ditaa blocks, etc…
>
> [image: blue.png]
>
>    - *blockquotes*
>
>    HTML e-mail is the use of a subset of HTML (often ill-defined) to
>    provide formatting and semantic markup capabilities in e-mail that are not
>    available with plain text. – wikipedia
>
>     - fontified *code blocks* (shown below)
>    - and *HTML character* conversion, like ∀ character c s.t. ∃ h ∈ *HTML
>    characters* and c ≡ h, org-html-export of c results in h
>
>
>
> The original org-mode formatted plain text is included as a text/plain
> mime alternative to the generated html.
>
> Below find the org-mime export of the org-mime worg page which will be
> available at http://orgmode.org/worg/org-contrib/org-mime.php.
>
> Best -- Eric
>
> General
>
> 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.
>
>   How to use it
>  Setup
>
> org-mime exposes two functions
>  `org-mime-htmlize' can be called from within a mail composition buffer to
> export either the entire buffer or just the active region to html, and embed
> the results into the buffer as a text/html mime section.
>
> 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' can be called from within an Org-mode
> buffer to export either the whole buffer or the narrowed subtree or active
> region to HTML, and open a new email buffer including the resulting HTML
> content as an embedded mime section.
>
> 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)))
>
>   CSS style customization
>
> 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.
>
>    - for those who use color themes with Dark backgrounds it is useful to
>    set a dark background for all exported code blocks and example regions. This
>    can be accomplished with the following
>
>    (add-hook 'org-mime-html-hook
>              (lambda ()
>                (org-mime-change-element-style
>                 "pre" (format "color: %s; background-color: %s; padding: 0.5em;"
>                               "#E6E1DC" "#232323"))))
>
>     - the following can be used to nicely offset block quotes in email
>    bodies
>
>    (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.
>   Credits
>
> org-mime was developed by Eric Schulte with much-appreciated help and
> discussion from everyone on the "using orgmode to send html mail<http://thread.gmane.org/gmane.emacs.orgmode/23153>"
> thread especially David Maus.
>
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
> > Carsten Dominik <carsten.dominik@gmail.com> writes:
> >
> >> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
> >>
> >>> Hi,
> >>>
> >>> It is now possible to send HTML mail directly form an org-mode buffer.
> >>>
> >>> Calling `org-mime-org-buffer-htmlize' (could probably use a better
> >>> name)
> >>> from inside of an org-mode buffer will use `org-export-as-html' to
> >>> generate HTML of the buffer (respecting regions and subtree
> >>> narrowing),
> >>> and will then package the resulting HTML with all linked images into a
> >>> message buffer.
> >>>
> >>> As usual thanks to Carsten's thoughtfully organized functions and
> >>> control variables this was surprisingly easy to implement.
> >>>
> >>> Cheers -- Eric
> >>>
> >>> The code is still up at http://github.com/eschulte/org-mime
> >>
> >> CONTIRB?  yes, after the release.....
> >>
> >
> > Sounds great, I'm move this into contrib then. -- Eric
> >
> >>
> >> - Carsten
> >>
> >>>
> >>> "Eric Schulte" <schulte.eric@gmail.com> writes:
> >>>
> >>>> Dan Davison <davison@stats.ox.ac.uk> writes:
> >>>>
> >>>> [...]
> >>>>
> >>>>>
> >>>>> As I understand it the code you've written is designed to be
> >>>>> called in a
> >>>>> message-mode buffer with orgstruct-mode in force. Would it make
> >>>>> sense to
> >>>>> also include in your package a complementary function, that one
> >>>>> calls in
> >>>>> an org-mode buffer? I envisage this generating the HTML, forming the
> >>>>> multipart email contents, and then saving it to the kill ring, so
> >>>>> that
> >>>>> it can be pasted into an email.
> >>>>>
> >>>>> This function would have access to the directory-name and so
> >>>>> should be
> >>>>> able to resolve relative paths. Also, there might be some other
> >>>>> advantages -- for example when exporting just a region or subtree,
> >>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up
> >>>>> by the
> >>>>> org exporter and packaged into the HTML.
> >>>>>
> >>>>> In other words, can I use your machinery to package up the HTML
> >>>>> generated by Org's C-e dispatcher into an appropriately-constructed
> >>>>> email?
> >>>>>
> >>>>
> >>>> Hi Dan,
> >>>>
> >>>> That sounds like a good idea, I've added it to a fledgling task list
> >>>> packaged in the README at [1].  I'd say there are two options.
> >>>>
> >>>> 1) which you mentioned saving the entire exported content to the
> >>>>   kill-ring.  One problem here is that everything is still text and
> >>>>   pastable only *before* the mime export process, which means that
> >>>>   linked images wouldn't resolve after pasting into the email client.
> >>>>
> >>>> 2) having the function generate a new mail buffer containing the
> >>>>   exported content.  This buffer would need to have it's
> >>>>   `buffer-file-name' set, for images to resolve during export.  I'm
> >>>> not
> >>>>   sure how this should best work.
> >>>>
> >>>> Thanks -- Eric
> >>>>
> >>>> Footnotes:
> >>>> [1]  http://github.com/eschulte/org-mime
> >>>
> >>>
> >>> _______________________________________________
> >>> Emacs-orgmode mailing list
> >>> Please use `Reply All' to send replies to the list.
> >>> Emacs-orgmode@gnu.org
> >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >>
> >> - Carsten
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>

[-- Attachment #1.1.2: Type: text/html, Size: 16041 bytes --]

[-- Attachment #1.2: blue.png --]
[-- Type: image/png, Size: 2087 bytes --]

[-- Attachment #1.3: mail78058-A_b023893fa20418a1525cad63accc444e9a8954d3.png --]
[-- Type: image/png, Size: 2165 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-12 13:37                                           ` Andrew Hyatt
@ 2010-04-12 17:22                                             ` Eric Schulte
  2010-04-13  1:31                                               ` Andrew Hyatt
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-12 17:22 UTC (permalink / raw)
  To: Andrew Hyatt; +Cc: emacs-orgmode

Hi Andrew,

Thanks for the report.  My guess is that somehow the call to
org-export-as-html is erroring out because some org-mode variables
aren't being set, maybe you don't have orgstruct-mode as a minor-mode in
your email composition -- not that it's required, but that could be the
difference between our setups which is causing you to see the bug and
not me.

I've changed the `org-mime-org-export' so it more closely mimics the
`org-run-like-in-org-mode' wrapping function, which should hopefully fix
this problem.  Please let me know either way, and if the problem
persists we can try to figure out exactly which variable isn't being
initialized.

Thanks for the report! -- Eric

Andrew Hyatt <ahyatt@gmail.com> writes:

> This looks great.  However, I get an error on my test mail:
>
> This is should be HTML mode.
>
> ~foo~
> =bar=
> _baz_
>
> | Table | A |
> | 1     | 2 |
>
> On calling org-mime-htmlize
>
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   string-match(nil #("This is should be HTML mode." 0 28 (fontified t)))
>   byte-code("\304\211.\x19\305\n\v\"\203A
>   org-html-handle-time-stamps(#("This is should be HTML mode." 0 28
> (fontified t)))
>   byte-code("\b\203.
>   org-export-as-html(nil nil nil string t)
>   (let nil (org-export-as-html nil nil nil (quote string) t))
>   eval((let nil (org-export-as-html nil nil nil (quote string) t)))
>   (progn (insert org-mime-default-header) (insert body) (write-file
> tmp-file) (eval (list ... org-local-vars ...)))
>   (unwind-protect (progn (insert org-mime-default-header) (insert body)
> (write-file tmp-file) (eval ...)) (and (buffer-name temp-buffer)
> (kill-buffer temp-buffer)))
>   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...
> ... ... ...) (and ... ...)))
>   (with-current-buffer temp-buffer (unwind-protect (progn ... ... ... ...)
> (and ... ...)))
>   (let ((temp-buffer ...)) (with-current-buffer temp-buffer (unwind-protect
> ... ...)))
>   (with-temp-buffer (insert org-mime-default-header) (insert body)
> (write-file tmp-file) (eval (list ... org-local-vars ...)))
>   (save-excursion (with-temp-buffer (insert org-mime-default-header) (insert
> body) (write-file tmp-file) (eval ...)))
>   org-mime-org-export("html" #("\nThis is should be HTML
> mode.\n\n~foo~\n=bar=\n_baz_\n\n| Table | A |\n| 1     | 2 | \n\n-- \n" 0 1
> (fontified t) 1 42 (fontified t) 42 43 (fontified t) 43 44 (article-type
> emphasis fontified t) 44 47 (fontified t) 47 48 (article-type emphasis
> fontified t) 48 50 (fontified t) 50 63 (fontified t face (gnus-cite-1
> message-cited-text)) 63 64 (fontified t) 64 78 (fontified t face
> (gnus-cite-1 message-cited-text)) 78 79 (fontified t rear-nonsticky t) 79 80
> (fontified t) 80 84 (fontified t)) "/tmp/mail2522NRw")
>   (org-mime-replace-images (org-mime-org-export "html" raw-body tmp-file)
> tmp-file)
>   (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
> (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
> (org-export-htmlize-output-type ...) (org-export-preserve-breaks
> org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
> ...)) (delete-region html-start html-end) (save-excursion (goto-char
> html-start) (insert ... ...)))
>   org-mime-htmlize(nil)
>
>
> On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com>wrote:
>
>> Announcing the addition of org-mime to the contrib directory of Org-mode
>>
>> this allows sending HTML email using org-mode including...
>>
>>
>>    - *tables*   colname onecolname two  11 24 39
>>    - *inline images* including latex equations [image: $f(n) = n +
>>    \frac{1}{n} \int_{0}^{n}{d_x f(x) + f(n - x)}$] and the results of
>>    ditaa blocks, etc…
>>
>> [image: blue.png]
>>
>>    - *blockquotes*
>>
>>    HTML e-mail is the use of a subset of HTML (often ill-defined) to
>>    provide formatting and semantic markup capabilities in e-mail that are not
>>    available with plain text. – wikipedia
>>
>>     - fontified *code blocks* (shown below)
>>    - and *HTML character* conversion, like ∀ character c s.t. ∃ h ∈ *HTML
>>    characters* and c ≡ h, org-html-export of c results in h
>>
>>
>>
>> The original org-mode formatted plain text is included as a text/plain
>> mime alternative to the generated html.
>>
>> Below find the org-mime export of the org-mime worg page which will be
>> available at http://orgmode.org/worg/org-contrib/org-mime.php.
>>
>> Best -- Eric
>>
>> General
>>
>> 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.
>>
>>   How to use it
>>  Setup
>>
>> org-mime exposes two functions
>>  `org-mime-htmlize' can be called from within a mail composition buffer to
>> export either the entire buffer or just the active region to html, and embed
>> the results into the buffer as a text/html mime section.
>>
>> 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' can be called from within an Org-mode
>> buffer to export either the whole buffer or the narrowed subtree or active
>> region to HTML, and open a new email buffer including the resulting HTML
>> content as an embedded mime section.
>>
>> 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)))
>>
>>   CSS style customization
>>
>> 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.
>>
>>    - for those who use color themes with Dark backgrounds it is useful to
>>    set a dark background for all exported code blocks and example regions. This
>>    can be accomplished with the following
>>
>>    (add-hook 'org-mime-html-hook
>>              (lambda ()
>>                (org-mime-change-element-style
>>                 "pre" (format "color: %s; background-color: %s; padding: 0.5em;"
>>                               "#E6E1DC" "#232323"))))
>>
>>     - the following can be used to nicely offset block quotes in email
>>    bodies
>>
>>    (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.
>>   Credits
>>
>> org-mime was developed by Eric Schulte with much-appreciated help and
>> discussion from everyone on the "using orgmode to send html mail<http://thread.gmane.org/gmane.emacs.orgmode/23153>"
>> thread especially David Maus.
>>
>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>
>> > Carsten Dominik <carsten.dominik@gmail.com> writes:
>> >
>> >> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> It is now possible to send HTML mail directly form an org-mode buffer.
>> >>>
>> >>> Calling `org-mime-org-buffer-htmlize' (could probably use a better
>> >>> name)
>> >>> from inside of an org-mode buffer will use `org-export-as-html' to
>> >>> generate HTML of the buffer (respecting regions and subtree
>> >>> narrowing),
>> >>> and will then package the resulting HTML with all linked images into a
>> >>> message buffer.
>> >>>
>> >>> As usual thanks to Carsten's thoughtfully organized functions and
>> >>> control variables this was surprisingly easy to implement.
>> >>>
>> >>> Cheers -- Eric
>> >>>
>> >>> The code is still up at http://github.com/eschulte/org-mime
>> >>
>> >> CONTIRB?  yes, after the release.....
>> >>
>> >
>> > Sounds great, I'm move this into contrib then. -- Eric
>> >
>> >>
>> >> - Carsten
>> >>
>> >>>
>> >>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> >>>
>> >>>> Dan Davison <davison@stats.ox.ac.uk> writes:
>> >>>>
>> >>>> [...]
>> >>>>
>> >>>>>
>> >>>>> As I understand it the code you've written is designed to be
>> >>>>> called in a
>> >>>>> message-mode buffer with orgstruct-mode in force. Would it make
>> >>>>> sense to
>> >>>>> also include in your package a complementary function, that one
>> >>>>> calls in
>> >>>>> an org-mode buffer? I envisage this generating the HTML, forming the
>> >>>>> multipart email contents, and then saving it to the kill ring, so
>> >>>>> that
>> >>>>> it can be pasted into an email.
>> >>>>>
>> >>>>> This function would have access to the directory-name and so
>> >>>>> should be
>> >>>>> able to resolve relative paths. Also, there might be some other
>> >>>>> advantages -- for example when exporting just a region or subtree,
>> >>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up
>> >>>>> by the
>> >>>>> org exporter and packaged into the HTML.
>> >>>>>
>> >>>>> In other words, can I use your machinery to package up the HTML
>> >>>>> generated by Org's C-e dispatcher into an appropriately-constructed
>> >>>>> email?
>> >>>>>
>> >>>>
>> >>>> Hi Dan,
>> >>>>
>> >>>> That sounds like a good idea, I've added it to a fledgling task list
>> >>>> packaged in the README at [1].  I'd say there are two options.
>> >>>>
>> >>>> 1) which you mentioned saving the entire exported content to the
>> >>>>   kill-ring.  One problem here is that everything is still text and
>> >>>>   pastable only *before* the mime export process, which means that
>> >>>>   linked images wouldn't resolve after pasting into the email client.
>> >>>>
>> >>>> 2) having the function generate a new mail buffer containing the
>> >>>>   exported content.  This buffer would need to have it's
>> >>>>   `buffer-file-name' set, for images to resolve during export.  I'm
>> >>>> not
>> >>>>   sure how this should best work.
>> >>>>
>> >>>> Thanks -- Eric
>> >>>>
>> >>>> Footnotes:
>> >>>> [1]  http://github.com/eschulte/org-mime
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> Emacs-orgmode mailing list
>> >>> Please use `Reply All' to send replies to the list.
>> >>> Emacs-orgmode@gnu.org
>> >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>> >>
>> >> - Carsten
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-12 17:22                                             ` Eric Schulte
@ 2010-04-13  1:31                                               ` Andrew Hyatt
  2010-04-14  0:57                                                 ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Andrew Hyatt @ 2010-04-13  1:31 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 14960 bytes --]

Thanks for the response.  I upgraded, now I get a

Debugger entered--Lisp error: (wrong-type-argument arrayp t)
 substring(t 33)
 (progn (insert org-mime-default-header) (insert body) (write-file tmp-file)
(org-load-modules-maybe) (unless org-local-vars (setq org-local-vars ...))
(substring (eval ...) (if ... ... 0)))
 (unwind-protect (progn (insert org-mime-default-header) (insert body)
(write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars ...)
(substring ... ...)) (and (buffer-name temp-buffer) (kill-buffer
temp-buffer)))
 (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...
... ... ... ... ...) (and ... ...)))
 (with-current-buffer temp-buffer (unwind-protect (progn ... ... ... ... ...
...) (and ... ...)))
 (let ((temp-buffer ...)) (with-current-buffer temp-buffer (unwind-protect
... ...)))
 (with-temp-buffer (insert org-mime-default-header) (insert body)
(write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars (setq
org-local-vars ...)) (substring (eval ...) (if ... ... 0)))
 (save-excursion (with-temp-buffer (insert org-mime-default-header) (insert
body) (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
...) (substring ... ...)))
 org-mime-org-export("org" #("\nHTML test\n\n~foo~\n=bar=\n_baz_\n\n| 1 | 2
|\n| a | b |\n" 0 1 (fontified t) 1 11 (fontified t) 11 12 (fontified t) 12
18 (fontified t) 18 24 (fontified t) 24 30 (fontified t) 30 31 (fontified t)
31 40 (fontified t face (gnus-cite-1 message-cited-text)) 40 41 (fontified
t) 41 50 (fontified t face (gnus-cite-1 message-cited-text)) 50 51
(fontified t)) "/tmp/mail2522ZvL")
 (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
(tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
(org-export-htmlize-output-type ...) (org-export-preserve-breaks
org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
...)) (delete-region html-start html-end) (save-excursion (goto-char
html-start) (insert ... ...)))
 org-mime-htmlize(nil)
 call-interactively(org-mime-htmlize record nil)

I tried this with orgstruct-mode off and on, but it was the same error
either way.  Earlier, before I got the latest version, I tried with
orgstruct-mode on, and it successfull htmlized my mail. But, when I received
it, the mail only contained the word "nil".

On Mon, Apr 12, 2010 at 1:22 PM, Eric Schulte <schulte.eric@gmail.com>wrote:

> Hi Andrew,
>
> Thanks for the report.  My guess is that somehow the call to
> org-export-as-html is erroring out because some org-mode variables
> aren't being set, maybe you don't have orgstruct-mode as a minor-mode in
> your email composition -- not that it's required, but that could be the
> difference between our setups which is causing you to see the bug and
> not me.
>
> I've changed the `org-mime-org-export' so it more closely mimics the
> `org-run-like-in-org-mode' wrapping function, which should hopefully fix
> this problem.  Please let me know either way, and if the problem
> persists we can try to figure out exactly which variable isn't being
> initialized.
>
> Thanks for the report! -- Eric
>
> Andrew Hyatt <ahyatt@gmail.com> writes:
>
> > This looks great.  However, I get an error on my test mail:
> >
> > This is should be HTML mode.
> >
> > ~foo~
> > =bar=
> > _baz_
> >
> > | Table | A |
> > | 1     | 2 |
> >
> > On calling org-mime-htmlize
> >
> > Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> >   string-match(nil #("This is should be HTML mode." 0 28 (fontified t)))
> >   byte-code("\304\211. \305\n \"\203A
> >   org-html-handle-time-stamps(#("This is should be HTML mode." 0 28
> > (fontified t)))
> >   byte-code(" \203.
> >   org-export-as-html(nil nil nil string t)
> >   (let nil (org-export-as-html nil nil nil (quote string) t))
> >   eval((let nil (org-export-as-html nil nil nil (quote string) t)))
> >   (progn (insert org-mime-default-header) (insert body) (write-file
> > tmp-file) (eval (list ... org-local-vars ...)))
> >   (unwind-protect (progn (insert org-mime-default-header) (insert body)
> > (write-file tmp-file) (eval ...)) (and (buffer-name temp-buffer)
> > (kill-buffer temp-buffer)))
> >   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
> ...
> > ... ... ...) (and ... ...)))
> >   (with-current-buffer temp-buffer (unwind-protect (progn ... ... ...
> ...)
> > (and ... ...)))
> >   (let ((temp-buffer ...)) (with-current-buffer temp-buffer
> (unwind-protect
> > ... ...)))
> >   (with-temp-buffer (insert org-mime-default-header) (insert body)
> > (write-file tmp-file) (eval (list ... org-local-vars ...)))
> >   (save-excursion (with-temp-buffer (insert org-mime-default-header)
> (insert
> > body) (write-file tmp-file) (eval ...)))
> >   org-mime-org-export("html" #("\nThis is should be HTML
> > mode.\n\n~foo~\n=bar=\n_baz_\n\n| Table | A |\n| 1     | 2 | \n\n-- \n" 0
> 1
> > (fontified t) 1 42 (fontified t) 42 43 (fontified t) 43 44 (article-type
> > emphasis fontified t) 44 47 (fontified t) 47 48 (article-type emphasis
> > fontified t) 48 50 (fontified t) 50 63 (fontified t face (gnus-cite-1
> > message-cited-text)) 63 64 (fontified t) 64 78 (fontified t face
> > (gnus-cite-1 message-cited-text)) 78 79 (fontified t rear-nonsticky t) 79
> 80
> > (fontified t) 80 84 (fontified t)) "/tmp/mail2522NRw")
> >   (org-mime-replace-images (org-mime-org-export "html" raw-body tmp-file)
> > tmp-file)
> >   (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
> > ...)) (delete-region html-start html-end) (save-excursion (goto-char
> > html-start) (insert ... ...)))
> >   org-mime-htmlize(nil)
> >
> >
> > On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com
> >wrote:
> >
> >> Announcing the addition of org-mime to the contrib directory of Org-mode
> >>
> >> this allows sending HTML email using org-mode including...
> >>
> >>
> >>    - *tables*   colname onecolname two  11 24 39
> >>    - *inline images* including latex equations [image: $f(n) = n +
> >>    \frac{1}{n} \int_{0}^{n}{d_x f(x) + f(n - x)}$] and the results of
> >>    ditaa blocks, etc…
> >>
> >> [image: blue.png]
> >>
> >>    - *blockquotes*
> >>
> >>    HTML e-mail is the use of a subset of HTML (often ill-defined) to
> >>    provide formatting and semantic markup capabilities in e-mail that
> are not
> >>    available with plain text. – wikipedia
> >>
> >>     - fontified *code blocks* (shown below)
> >>    - and *HTML character* conversion, like ∀ character c s.t. ∃ h ∈
> *HTML
> >>    characters* and c ≡ h, org-html-export of c results in h
> >>
> >>
> >>
> >> The original org-mode formatted plain text is included as a text/plain
> >> mime alternative to the generated html.
> >>
> >> Below find the org-mime export of the org-mime worg page which will be
> >> available at http://orgmode.org/worg/org-contrib/org-mime.php.
> >>
> >> Best -- Eric
> >>
> >> General
> >>
> >> 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.
> >>
> >>   How to use it
> >>  Setup
> >>
> >> org-mime exposes two functions
> >>  `org-mime-htmlize' can be called from within a mail composition buffer
> to
> >> export either the entire buffer or just the active region to html, and
> embed
> >> the results into the buffer as a text/html mime section.
> >>
> >> 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' can be called from within an Org-mode
> >> buffer to export either the whole buffer or the narrowed subtree or
> active
> >> region to HTML, and open a new email buffer including the resulting HTML
> >> content as an embedded mime section.
> >>
> >> 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)))
> >>
> >>   CSS style customization
> >>
> >> 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.
> >>
> >>    - for those who use color themes with Dark backgrounds it is useful
> to
> >>    set a dark background for all exported code blocks and example
> regions. This
> >>    can be accomplished with the following
> >>
> >>    (add-hook 'org-mime-html-hook
> >>              (lambda ()
> >>                (org-mime-change-element-style
> >>                 "pre" (format "color: %s; background-color: %s; padding:
> 0.5em;"
> >>                               "#E6E1DC" "#232323"))))
> >>
> >>     - the following can be used to nicely offset block quotes in email
> >>    bodies
> >>
> >>    (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.
> >>   Credits
> >>
> >> org-mime was developed by Eric Schulte with much-appreciated help and
> >> discussion from everyone on the "using orgmode to send html mail<
> http://thread.gmane.org/gmane.emacs.orgmode/23153>"
> >> thread especially David Maus.
> >>
> >> "Eric Schulte" <schulte.eric@gmail.com> writes:
> >>
> >> > Carsten Dominik <carsten.dominik@gmail.com> writes:
> >> >
> >> >> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
> >> >>
> >> >>> Hi,
> >> >>>
> >> >>> It is now possible to send HTML mail directly form an org-mode
> buffer.
> >> >>>
> >> >>> Calling `org-mime-org-buffer-htmlize' (could probably use a better
> >> >>> name)
> >> >>> from inside of an org-mode buffer will use `org-export-as-html' to
> >> >>> generate HTML of the buffer (respecting regions and subtree
> >> >>> narrowing),
> >> >>> and will then package the resulting HTML with all linked images into
> a
> >> >>> message buffer.
> >> >>>
> >> >>> As usual thanks to Carsten's thoughtfully organized functions and
> >> >>> control variables this was surprisingly easy to implement.
> >> >>>
> >> >>> Cheers -- Eric
> >> >>>
> >> >>> The code is still up at http://github.com/eschulte/org-mime
> >> >>
> >> >> CONTIRB?  yes, after the release.....
> >> >>
> >> >
> >> > Sounds great, I'm move this into contrib then. -- Eric
> >> >
> >> >>
> >> >> - Carsten
> >> >>
> >> >>>
> >> >>> "Eric Schulte" <schulte.eric@gmail.com> writes:
> >> >>>
> >> >>>> Dan Davison <davison@stats.ox.ac.uk> writes:
> >> >>>>
> >> >>>> [...]
> >> >>>>
> >> >>>>>
> >> >>>>> As I understand it the code you've written is designed to be
> >> >>>>> called in a
> >> >>>>> message-mode buffer with orgstruct-mode in force. Would it make
> >> >>>>> sense to
> >> >>>>> also include in your package a complementary function, that one
> >> >>>>> calls in
> >> >>>>> an org-mode buffer? I envisage this generating the HTML, forming
> the
> >> >>>>> multipart email contents, and then saving it to the kill ring, so
> >> >>>>> that
> >> >>>>> it can be pasted into an email.
> >> >>>>>
> >> >>>>> This function would have access to the directory-name and so
> >> >>>>> should be
> >> >>>>> able to resolve relative paths. Also, there might be some other
> >> >>>>> advantages -- for example when exporting just a region or subtree,
> >> >>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up
> >> >>>>> by the
> >> >>>>> org exporter and packaged into the HTML.
> >> >>>>>
> >> >>>>> In other words, can I use your machinery to package up the HTML
> >> >>>>> generated by Org's C-e dispatcher into an
> appropriately-constructed
> >> >>>>> email?
> >> >>>>>
> >> >>>>
> >> >>>> Hi Dan,
> >> >>>>
> >> >>>> That sounds like a good idea, I've added it to a fledgling task
> list
> >> >>>> packaged in the README at [1].  I'd say there are two options.
> >> >>>>
> >> >>>> 1) which you mentioned saving the entire exported content to the
> >> >>>>   kill-ring.  One problem here is that everything is still text and
> >> >>>>   pastable only *before* the mime export process, which means that
> >> >>>>   linked images wouldn't resolve after pasting into the email
> client.
> >> >>>>
> >> >>>> 2) having the function generate a new mail buffer containing the
> >> >>>>   exported content.  This buffer would need to have it's
> >> >>>>   `buffer-file-name' set, for images to resolve during export.  I'm
> >> >>>> not
> >> >>>>   sure how this should best work.
> >> >>>>
> >> >>>> Thanks -- Eric
> >> >>>>
> >> >>>> Footnotes:
> >> >>>> [1]  http://github.com/eschulte/org-mime
> >> >>>
> >> >>>
> >> >>> _______________________________________________
> >> >>> Emacs-orgmode mailing list
> >> >>> Please use `Reply All' to send replies to the list.
> >> >>> Emacs-orgmode@gnu.org
> >> >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >> >>
> >> >> - Carsten
> >>
> >> _______________________________________________
> >> Emacs-orgmode mailing list
> >> Please use `Reply All' to send replies to the list.
> >> Emacs-orgmode@gnu.org
> >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >>
> >>
>

[-- Attachment #1.2: Type: text/html, Size: 20323 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-09 16:41                                         ` [ANN] org-mime -- " Eric Schulte
  2010-04-09 17:41                                           ` Matt Price
  2010-04-12 13:37                                           ` Andrew Hyatt
@ 2010-04-13 23:03                                           ` Eric S Fraga
  2010-04-14  1:22                                             ` Eric Schulte
  2 siblings, 1 reply; 63+ messages in thread
From: Eric S Fraga @ 2010-04-13 23:03 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

Eric,

I have been away a couple of weeks where I have avoided using email as
much as possible.  I have therefore come back to find this whole
incredible thread that has led to org-mime.  Very exciting!  Although
I'm not a big fan of html email in general, an easy to use mime
interface which allows me to embed equations easily is very welcome.

However, it doesn't appear to work very well for me, with org-mode
from git as of a couple of hours ago:

- GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.2) of
  2009-11-02 on raven, modified by Debian

- Org-mode version 6.35g (release_6.35g.41.g9cfe)

- Wanderlust/2.15.9 (Almost Unreal)

What I get when I try your example, by copying your original org text
into my email buffer and invoking org-mime-htmlize, is:

,----
| 

[-- Attachment #2.1: Type: text/plain, Size: 2 bytes --]

| 

[-- Attachment #2.2: Type: text/plain, Size: 1028 bytes --]

| #+OPTIONS: latex:t

| - *tables*
|   | colname one | colname two |
|   |-------------+-------------|
|   |           1 |           1 |
|   |           2 |           4 |
|   |           3 |           9 | 
| 
| - *inline images* including latex equations $f(n) = n + \frac{1}{n}
|   \int_{0}^{n}{d_x f(x) + f(n - x)}$ and the results of ditaa blocks,
|   etc...
| 
|   #+begin_src ditaa :file blue.png :cmdline -r
|   +---------+
|   | cBLU    |
|   |         |
|   |    +----+
|   |    |cPNK|
|   |    |    |
|   +----+----+
|   #+end_src
| 
| - *blockquotes*
|   #+begin_quote
|     HTML e-mail is the use of a subset of HTML (often ill-defined) to
|     provide formatting and semantic markup capabilities in e-mail that
|     are not available with plain text. -- wikipedia
|   #+end_quote
| 
| - fontified *code blocks* (shown below)
| 
| - and *HTML character* conversion, like \forall character c s.t. \exists
|   h \in /HTML characters/ and c \equiv h, org-html-export of c results
|   in h
| 
| --; charset=US-ASCII

| 

[-- Attachment #2.3: Type: text/html, Size: 26 bytes --]

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]

| 

[-- Attachment #4: Type: application/octet-stream, Size: 91 bytes --]

| Content-ID: _tmp_blue.png; filename="/tmp/blue.png"
Content-Transfer-Encoding: base64

| 

[-- Attachment #5: Type: application/octet-stream, Size: 289 bytes --]

| Content-ID: _tmp_ltxpng_mail4440T8b_9f0d38150575fa038fe726ff71e561fc45b25baa.png; filename="/tmp/ltxpng/mail4440T8b_9f0d38150575fa038fe726ff71e561fc45b25baa.png"
Content-Transfer-Encoding: base64

`----


Note the "nil" text/html entry.

What silly thing am I doing wrong?

Thanks,
eric

[-- Attachment #6: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-13  1:31                                               ` Andrew Hyatt
@ 2010-04-14  0:57                                                 ` Eric Schulte
  2010-04-14  1:57                                                   ` Andrew Hyatt
  2010-04-14  8:39                                                   ` Eric S Fraga
  0 siblings, 2 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-14  0:57 UTC (permalink / raw)
  To: Andrew Hyatt; +Cc: emacs-orgmode

So, for some reason the `org-mime-org-export' helper function is
returning nil on your (and Eric's) machines.  Could you try evaluating
(C-M-x) the following in your *scratch* buffer?

(insert (org-mime-org-export "html" "- first
- second
- third" (make-temp-file "quick-test")))

When I execute the above it inserts the following into the scratch
buffer

<ul>
<li>
first
</li>
<li>
second
</li>
<li>
third
</li>
</ul>

If instead you get an error, or it inserts nil, then it means that our
systems are somehow different with respect to that function, which is a
slight alteration of `org-run-like-in-org-mode'.

At that point you could try using something like

(org-run-like-in-org-mode 'org-export-as-html)

to export a non-html buffer to html, or you could also try starting up
Emacs with the -Q option, then loading org-mime.el, opening an org-mode
file, and calling org-mime-org-buffer-htmlize, and sending an email to
yourself.

Sorry I can't be of more help, I'm really mystified as to how this
function could be returning nil.

Best -- Eric

Andrew Hyatt <ahyatt@gmail.com> writes:

> Thanks for the response.  I upgraded, now I get a
>
> Debugger entered--Lisp error: (wrong-type-argument arrayp t)
>  substring(t 33)
>  (progn (insert org-mime-default-header) (insert body) (write-file tmp-file)
> (org-load-modules-maybe) (unless org-local-vars (setq org-local-vars ...))
> (substring (eval ...) (if ... ... 0)))
>  (unwind-protect (progn (insert org-mime-default-header) (insert body)
> (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars ...)
> (substring ... ...)) (and (buffer-name temp-buffer) (kill-buffer
> temp-buffer)))
>  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...
> ... ... ... ... ...) (and ... ...)))
>  (with-current-buffer temp-buffer (unwind-protect (progn ... ... ... ... ...
> ...) (and ... ...)))
>  (let ((temp-buffer ...)) (with-current-buffer temp-buffer (unwind-protect
> ... ...)))
>  (with-temp-buffer (insert org-mime-default-header) (insert body)
> (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars (setq
> org-local-vars ...)) (substring (eval ...) (if ... ... 0)))
>  (save-excursion (with-temp-buffer (insert org-mime-default-header) (insert
> body) (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
> ...) (substring ... ...)))
>  org-mime-org-export("org" #("\nHTML test\n\n~foo~\n=bar=\n_baz_\n\n| 1 | 2
> |\n| a | b |\n" 0 1 (fontified t) 1 11 (fontified t) 11 12 (fontified t) 12
> 18 (fontified t) 18 24 (fontified t) 24 30 (fontified t) 30 31 (fontified t)
> 31 40 (fontified t face (gnus-cite-1 message-cited-text)) 40 41 (fontified
> t) 41 50 (fontified t face (gnus-cite-1 message-cited-text)) 50 51
> (fontified t)) "/tmp/mail2522ZvL")
>  (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
> (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
> (org-export-htmlize-output-type ...) (org-export-preserve-breaks
> org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
> ...)) (delete-region html-start html-end) (save-excursion (goto-char
> html-start) (insert ... ...)))
>  org-mime-htmlize(nil)
>  call-interactively(org-mime-htmlize record nil)
>
> I tried this with orgstruct-mode off and on, but it was the same error
> either way.  Earlier, before I got the latest version, I tried with
> orgstruct-mode on, and it successfull htmlized my mail. But, when I received
> it, the mail only contained the word "nil".
>
> On Mon, Apr 12, 2010 at 1:22 PM, Eric Schulte <schulte.eric@gmail.com>wrote:
>
>> Hi Andrew,
>>
>> Thanks for the report.  My guess is that somehow the call to
>> org-export-as-html is erroring out because some org-mode variables
>> aren't being set, maybe you don't have orgstruct-mode as a minor-mode in
>> your email composition -- not that it's required, but that could be the
>> difference between our setups which is causing you to see the bug and
>> not me.
>>
>> I've changed the `org-mime-org-export' so it more closely mimics the
>> `org-run-like-in-org-mode' wrapping function, which should hopefully fix
>> this problem.  Please let me know either way, and if the problem
>> persists we can try to figure out exactly which variable isn't being
>> initialized.
>>
>> Thanks for the report! -- Eric
>>
>> Andrew Hyatt <ahyatt@gmail.com> writes:
>>
>> > This looks great.  However, I get an error on my test mail:
>> >
>> > This is should be HTML mode.
>> >
>> > ~foo~
>> > =bar=
>> > _baz_
>> >
>> > | Table | A |
>> > | 1     | 2 |
>> >
>> > On calling org-mime-htmlize
>> >
>> > Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>> >   string-match(nil #("This is should be HTML mode." 0 28 (fontified t)))
>> >   byte-code("\304\211. \305\n \"\203A
>> >   org-html-handle-time-stamps(#("This is should be HTML mode." 0 28
>> > (fontified t)))
>> >   byte-code(" \203.
>> >   org-export-as-html(nil nil nil string t)
>> >   (let nil (org-export-as-html nil nil nil (quote string) t))
>> >   eval((let nil (org-export-as-html nil nil nil (quote string) t)))
>> >   (progn (insert org-mime-default-header) (insert body) (write-file
>> > tmp-file) (eval (list ... org-local-vars ...)))
>> >   (unwind-protect (progn (insert org-mime-default-header) (insert body)
>> > (write-file tmp-file) (eval ...)) (and (buffer-name temp-buffer)
>> > (kill-buffer temp-buffer)))
>> >   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
>> ...
>> > ... ... ...) (and ... ...)))
>> >   (with-current-buffer temp-buffer (unwind-protect (progn ... ... ...
>> ...)
>> > (and ... ...)))
>> >   (let ((temp-buffer ...)) (with-current-buffer temp-buffer
>> (unwind-protect
>> > ... ...)))
>> >   (with-temp-buffer (insert org-mime-default-header) (insert body)
>> > (write-file tmp-file) (eval (list ... org-local-vars ...)))
>> >   (save-excursion (with-temp-buffer (insert org-mime-default-header)
>> (insert
>> > body) (write-file tmp-file) (eval ...)))
>> >   org-mime-org-export("html" #("\nThis is should be HTML
>> > mode.\n\n~foo~\n=bar=\n_baz_\n\n| Table | A |\n| 1     | 2 | \n\n-- \n" 0
>> 1
>> > (fontified t) 1 42 (fontified t) 42 43 (fontified t) 43 44 (article-type
>> > emphasis fontified t) 44 47 (fontified t) 47 48 (article-type emphasis
>> > fontified t) 48 50 (fontified t) 50 63 (fontified t face (gnus-cite-1
>> > message-cited-text)) 63 64 (fontified t) 64 78 (fontified t face
>> > (gnus-cite-1 message-cited-text)) 78 79 (fontified t rear-nonsticky t) 79
>> 80
>> > (fontified t) 80 84 (fontified t)) "/tmp/mail2522NRw")
>> >   (org-mime-replace-images (org-mime-org-export "html" raw-body tmp-file)
>> > tmp-file)
>> >   (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
>> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
>> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
>> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
>> > ...)) (delete-region html-start html-end) (save-excursion (goto-char
>> > html-start) (insert ... ...)))
>> >   org-mime-htmlize(nil)
>> >
>> >
>> > On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com
>> >wrote:
>> >
>> >> Announcing the addition of org-mime to the contrib directory of Org-mode
>> >>
>> >> this allows sending HTML email using org-mode including...
>> >>
>> >>
>> >>    - *tables*   colname onecolname two  11 24 39
>> >>    - *inline images* including latex equations [image: $f(n) = n +
>> >>    \frac{1}{n} \int_{0}^{n}{d_x f(x) + f(n - x)}$] and the results of
>> >>    ditaa blocks, etc…
>> >>
>> >> [image: blue.png]
>> >>
>> >>    - *blockquotes*
>> >>
>> >>    HTML e-mail is the use of a subset of HTML (often ill-defined) to
>> >>    provide formatting and semantic markup capabilities in e-mail that
>> are not
>> >>    available with plain text. – wikipedia
>> >>
>> >>     - fontified *code blocks* (shown below)
>> >>    - and *HTML character* conversion, like ∀ character c s.t. ∃ h ∈
>> *HTML
>> >>    characters* and c ≡ h, org-html-export of c results in h
>> >>
>> >>
>> >>
>> >> The original org-mode formatted plain text is included as a text/plain
>> >> mime alternative to the generated html.
>> >>
>> >> Below find the org-mime export of the org-mime worg page which will be
>> >> available at http://orgmode.org/worg/org-contrib/org-mime.php.
>> >>
>> >> Best -- Eric
>> >>
>> >> General
>> >>
>> >> 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.
>> >>
>> >>   How to use it
>> >>  Setup
>> >>
>> >> org-mime exposes two functions
>> >>  `org-mime-htmlize' can be called from within a mail composition buffer
>> to
>> >> export either the entire buffer or just the active region to html, and
>> embed
>> >> the results into the buffer as a text/html mime section.
>> >>
>> >> 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' can be called from within an Org-mode
>> >> buffer to export either the whole buffer or the narrowed subtree or
>> active
>> >> region to HTML, and open a new email buffer including the resulting HTML
>> >> content as an embedded mime section.
>> >>
>> >> 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)))
>> >>
>> >>   CSS style customization
>> >>
>> >> 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.
>> >>
>> >>    - for those who use color themes with Dark backgrounds it is useful
>> to
>> >>    set a dark background for all exported code blocks and example
>> regions. This
>> >>    can be accomplished with the following
>> >>
>> >>    (add-hook 'org-mime-html-hook
>> >>              (lambda ()
>> >>                (org-mime-change-element-style
>> >>                 "pre" (format "color: %s; background-color: %s; padding:
>> 0.5em;"
>> >>                               "#E6E1DC" "#232323"))))
>> >>
>> >>     - the following can be used to nicely offset block quotes in email
>> >>    bodies
>> >>
>> >>    (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.
>> >>   Credits
>> >>
>> >> org-mime was developed by Eric Schulte with much-appreciated help and
>> >> discussion from everyone on the "using orgmode to send html mail<
>> http://thread.gmane.org/gmane.emacs.orgmode/23153>"
>> >> thread especially David Maus.
>> >>
>> >> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> >>
>> >> > Carsten Dominik <carsten.dominik@gmail.com> writes:
>> >> >
>> >> >> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
>> >> >>
>> >> >>> Hi,
>> >> >>>
>> >> >>> It is now possible to send HTML mail directly form an org-mode
>> buffer.
>> >> >>>
>> >> >>> Calling `org-mime-org-buffer-htmlize' (could probably use a better
>> >> >>> name)
>> >> >>> from inside of an org-mode buffer will use `org-export-as-html' to
>> >> >>> generate HTML of the buffer (respecting regions and subtree
>> >> >>> narrowing),
>> >> >>> and will then package the resulting HTML with all linked images into
>> a
>> >> >>> message buffer.
>> >> >>>
>> >> >>> As usual thanks to Carsten's thoughtfully organized functions and
>> >> >>> control variables this was surprisingly easy to implement.
>> >> >>>
>> >> >>> Cheers -- Eric
>> >> >>>
>> >> >>> The code is still up at http://github.com/eschulte/org-mime
>> >> >>
>> >> >> CONTIRB?  yes, after the release.....
>> >> >>
>> >> >
>> >> > Sounds great, I'm move this into contrib then. -- Eric
>> >> >
>> >> >>
>> >> >> - Carsten
>> >> >>
>> >> >>>
>> >> >>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> >> >>>
>> >> >>>> Dan Davison <davison@stats.ox.ac.uk> writes:
>> >> >>>>
>> >> >>>> [...]
>> >> >>>>
>> >> >>>>>
>> >> >>>>> As I understand it the code you've written is designed to be
>> >> >>>>> called in a
>> >> >>>>> message-mode buffer with orgstruct-mode in force. Would it make
>> >> >>>>> sense to
>> >> >>>>> also include in your package a complementary function, that one
>> >> >>>>> calls in
>> >> >>>>> an org-mode buffer? I envisage this generating the HTML, forming
>> the
>> >> >>>>> multipart email contents, and then saving it to the kill ring, so
>> >> >>>>> that
>> >> >>>>> it can be pasted into an email.
>> >> >>>>>
>> >> >>>>> This function would have access to the directory-name and so
>> >> >>>>> should be
>> >> >>>>> able to resolve relative paths. Also, there might be some other
>> >> >>>>> advantages -- for example when exporting just a region or subtree,
>> >> >>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked up
>> >> >>>>> by the
>> >> >>>>> org exporter and packaged into the HTML.
>> >> >>>>>
>> >> >>>>> In other words, can I use your machinery to package up the HTML
>> >> >>>>> generated by Org's C-e dispatcher into an
>> appropriately-constructed
>> >> >>>>> email?
>> >> >>>>>
>> >> >>>>
>> >> >>>> Hi Dan,
>> >> >>>>
>> >> >>>> That sounds like a good idea, I've added it to a fledgling task
>> list
>> >> >>>> packaged in the README at [1].  I'd say there are two options.
>> >> >>>>
>> >> >>>> 1) which you mentioned saving the entire exported content to the
>> >> >>>>   kill-ring.  One problem here is that everything is still text and
>> >> >>>>   pastable only *before* the mime export process, which means that
>> >> >>>>   linked images wouldn't resolve after pasting into the email
>> client.
>> >> >>>>
>> >> >>>> 2) having the function generate a new mail buffer containing the
>> >> >>>>   exported content.  This buffer would need to have it's
>> >> >>>>   `buffer-file-name' set, for images to resolve during export.  I'm
>> >> >>>> not
>> >> >>>>   sure how this should best work.
>> >> >>>>
>> >> >>>> Thanks -- Eric
>> >> >>>>
>> >> >>>> Footnotes:
>> >> >>>> [1]  http://github.com/eschulte/org-mime
>> >> >>>
>> >> >>>
>> >> >>> _______________________________________________
>> >> >>> Emacs-orgmode mailing list
>> >> >>> Please use `Reply All' to send replies to the list.
>> >> >>> Emacs-orgmode@gnu.org
>> >> >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>> >> >>
>> >> >> - Carsten
>> >>
>> >> _______________________________________________
>> >> Emacs-orgmode mailing list
>> >> Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-13 23:03                                           ` Eric S Fraga
@ 2010-04-14  1:22                                             ` Eric Schulte
  0 siblings, 0 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-14  1:22 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode

Hi Eric,

It looks like you're having the same issue as Andrew.  Could you try the
suggestions I put in the email to him and let me know the results?

Thanks -- Eric

Eric S Fraga <ucecesf@ucl.ac.uk> writes:

> Eric,
>
> I have been away a couple of weeks where I have avoided using email as
> much as possible.  I have therefore come back to find this whole
> incredible thread that has led to org-mime.  Very exciting!  Although
> I'm not a big fan of html email in general, an easy to use mime
> interface which allows me to embed equations easily is very welcome.
>
> However, it doesn't appear to work very well for me, with org-mode
> from git as of a couple of hours ago:
>
> - GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.2) of
>   2009-11-02 on raven, modified by Debian
>
> - Org-mode version 6.35g (release_6.35g.41.g9cfe)
>
> - Wanderlust/2.15.9 (Almost Unreal)
>
> What I get when I try your example, by copying your original org text
> into my email buffer and invoking org-mime-htmlize, is:
>
> ,----
> | | | 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14  0:57                                                 ` Eric Schulte
@ 2010-04-14  1:57                                                   ` Andrew Hyatt
  2010-04-14 14:59                                                     ` Eric Schulte
  2010-04-14  8:39                                                   ` Eric S Fraga
  1 sibling, 1 reply; 63+ messages in thread
From: Andrew Hyatt @ 2010-04-14  1:57 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 17746 bytes --]

I do get the same result you do.  Hopefully, I'll have some time tomorrow to
look into the issue.  RIght now, though, my problem is not the nil, but the
error I reported in my previous email.

On Tue, Apr 13, 2010 at 8:57 PM, Eric Schulte <schulte.eric@gmail.com>wrote:

> So, for some reason the `org-mime-org-export' helper function is
> returning nil on your (and Eric's) machines.  Could you try evaluating
> (C-M-x) the following in your *scratch* buffer?
>
> (insert (org-mime-org-export "html" "- first
> - second
> - third" (make-temp-file "quick-test")))
>
> When I execute the above it inserts the following into the scratch
> buffer
>
> <ul>
> <li>
> first
> </li>
> <li>
> second
> </li>
> <li>
> third
> </li>
> </ul>
>
> If instead you get an error, or it inserts nil, then it means that our
> systems are somehow different with respect to that function, which is a
> slight alteration of `org-run-like-in-org-mode'.
>
> At that point you could try using something like
>
> (org-run-like-in-org-mode 'org-export-as-html)
>
> to export a non-html buffer to html, or you could also try starting up
> Emacs with the -Q option, then loading org-mime.el, opening an org-mode
> file, and calling org-mime-org-buffer-htmlize, and sending an email to
> yourself.
>
> Sorry I can't be of more help, I'm really mystified as to how this
> function could be returning nil.
>
> Best -- Eric
>
> Andrew Hyatt <ahyatt@gmail.com> writes:
>
> > Thanks for the response.  I upgraded, now I get a
> >
> > Debugger entered--Lisp error: (wrong-type-argument arrayp t)
> >  substring(t 33)
> >  (progn (insert org-mime-default-header) (insert body) (write-file
> tmp-file)
> > (org-load-modules-maybe) (unless org-local-vars (setq org-local-vars
> ...))
> > (substring (eval ...) (if ... ... 0)))
> >  (unwind-protect (progn (insert org-mime-default-header) (insert body)
> > (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
> ...)
> > (substring ... ...)) (and (buffer-name temp-buffer) (kill-buffer
> > temp-buffer)))
> >  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...
> > ... ... ... ... ...) (and ... ...)))
> >  (with-current-buffer temp-buffer (unwind-protect (progn ... ... ... ...
> ...
> > ...) (and ... ...)))
> >  (let ((temp-buffer ...)) (with-current-buffer temp-buffer
> (unwind-protect
> > ... ...)))
> >  (with-temp-buffer (insert org-mime-default-header) (insert body)
> > (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
> (setq
> > org-local-vars ...)) (substring (eval ...) (if ... ... 0)))
> >  (save-excursion (with-temp-buffer (insert org-mime-default-header)
> (insert
> > body) (write-file tmp-file) (org-load-modules-maybe) (unless
> org-local-vars
> > ...) (substring ... ...)))
> >  org-mime-org-export("org" #("\nHTML test\n\n~foo~\n=bar=\n_baz_\n\n| 1 |
> 2
> > |\n| a | b |\n" 0 1 (fontified t) 1 11 (fontified t) 11 12 (fontified t)
> 12
> > 18 (fontified t) 18 24 (fontified t) 24 30 (fontified t) 30 31 (fontified
> t)
> > 31 40 (fontified t face (gnus-cite-1 message-cited-text)) 40 41
> (fontified
> > t) 41 50 (fontified t face (gnus-cite-1 message-cited-text)) 50 51
> > (fontified t)) "/tmp/mail2522ZvL")
> >  (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
> > ...)) (delete-region html-start html-end) (save-excursion (goto-char
> > html-start) (insert ... ...)))
> >  org-mime-htmlize(nil)
> >  call-interactively(org-mime-htmlize record nil)
> >
> > I tried this with orgstruct-mode off and on, but it was the same error
> > either way.  Earlier, before I got the latest version, I tried with
> > orgstruct-mode on, and it successfull htmlized my mail. But, when I
> received
> > it, the mail only contained the word "nil".
> >
> > On Mon, Apr 12, 2010 at 1:22 PM, Eric Schulte <schulte.eric@gmail.com
> >wrote:
> >
> >> Hi Andrew,
> >>
> >> Thanks for the report.  My guess is that somehow the call to
> >> org-export-as-html is erroring out because some org-mode variables
> >> aren't being set, maybe you don't have orgstruct-mode as a minor-mode in
> >> your email composition -- not that it's required, but that could be the
> >> difference between our setups which is causing you to see the bug and
> >> not me.
> >>
> >> I've changed the `org-mime-org-export' so it more closely mimics the
> >> `org-run-like-in-org-mode' wrapping function, which should hopefully fix
> >> this problem.  Please let me know either way, and if the problem
> >> persists we can try to figure out exactly which variable isn't being
> >> initialized.
> >>
> >> Thanks for the report! -- Eric
> >>
> >> Andrew Hyatt <ahyatt@gmail.com> writes:
> >>
> >> > This looks great.  However, I get an error on my test mail:
> >> >
> >> > This is should be HTML mode.
> >> >
> >> > ~foo~
> >> > =bar=
> >> > _baz_
> >> >
> >> > | Table | A |
> >> > | 1     | 2 |
> >> >
> >> > On calling org-mime-htmlize
> >> >
> >> > Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> >> >   string-match(nil #("This is should be HTML mode." 0 28 (fontified
> t)))
> >> >   byte-code("\304\211. \305\n \"\203A
> >> >   org-html-handle-time-stamps(#("This is should be HTML mode." 0 28
> >> > (fontified t)))
> >> >   byte-code(" \203.
> >> >   org-export-as-html(nil nil nil string t)
> >> >   (let nil (org-export-as-html nil nil nil (quote string) t))
> >> >   eval((let nil (org-export-as-html nil nil nil (quote string) t)))
> >> >   (progn (insert org-mime-default-header) (insert body) (write-file
> >> > tmp-file) (eval (list ... org-local-vars ...)))
> >> >   (unwind-protect (progn (insert org-mime-default-header) (insert
> body)
> >> > (write-file tmp-file) (eval ...)) (and (buffer-name temp-buffer)
> >> > (kill-buffer temp-buffer)))
> >> >   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
> >> ...
> >> > ... ... ...) (and ... ...)))
> >> >   (with-current-buffer temp-buffer (unwind-protect (progn ... ... ...
> >> ...)
> >> > (and ... ...)))
> >> >   (let ((temp-buffer ...)) (with-current-buffer temp-buffer
> >> (unwind-protect
> >> > ... ...)))
> >> >   (with-temp-buffer (insert org-mime-default-header) (insert body)
> >> > (write-file tmp-file) (eval (list ... org-local-vars ...)))
> >> >   (save-excursion (with-temp-buffer (insert org-mime-default-header)
> >> (insert
> >> > body) (write-file tmp-file) (eval ...)))
> >> >   org-mime-org-export("html" #("\nThis is should be HTML
> >> > mode.\n\n~foo~\n=bar=\n_baz_\n\n| Table | A |\n| 1     | 2 | \n\n--
> \n" 0
> >> 1
> >> > (fontified t) 1 42 (fontified t) 42 43 (fontified t) 43 44
> (article-type
> >> > emphasis fontified t) 44 47 (fontified t) 47 48 (article-type emphasis
> >> > fontified t) 48 50 (fontified t) 50 63 (fontified t face (gnus-cite-1
> >> > message-cited-text)) 63 64 (fontified t) 64 78 (fontified t face
> >> > (gnus-cite-1 message-cited-text)) 78 79 (fontified t rear-nonsticky t)
> 79
> >> 80
> >> > (fontified t) 80 84 (fontified t)) "/tmp/mail2522NRw")
> >> >   (org-mime-replace-images (org-mime-org-export "html" raw-body
> tmp-file)
> >> > tmp-file)
> >> >   (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
> >> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading
> nil)
> >> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
> >> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...)
> (html
> >> > ...)) (delete-region html-start html-end) (save-excursion (goto-char
> >> > html-start) (insert ... ...)))
> >> >   org-mime-htmlize(nil)
> >> >
> >> >
> >> > On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com
> >> >wrote:
> >> >
> >> >> Announcing the addition of org-mime to the contrib directory of
> Org-mode
> >> >>
> >> >> this allows sending HTML email using org-mode including...
> >> >>
> >> >>
> >> >>    - *tables*   colname onecolname two  11 24 39
> >> >>    - *inline images* including latex equations [image: $f(n) = n +
> >> >>    \frac{1}{n} \int_{0}^{n}{d_x f(x) + f(n - x)}$] and the results of
> >> >>    ditaa blocks, etc…
> >> >>
> >> >> [image: blue.png]
> >> >>
> >> >>    - *blockquotes*
> >> >>
> >> >>    HTML e-mail is the use of a subset of HTML (often ill-defined) to
> >> >>    provide formatting and semantic markup capabilities in e-mail that
> >> are not
> >> >>    available with plain text. – wikipedia
> >> >>
> >> >>     - fontified *code blocks* (shown below)
> >> >>    - and *HTML character* conversion, like ∀ character c s.t. ∃ h ∈
> >> *HTML
> >> >>    characters* and c ≡ h, org-html-export of c results in h
> >> >>
> >> >>
> >> >>
> >> >> The original org-mode formatted plain text is included as a
> text/plain
> >> >> mime alternative to the generated html.
> >> >>
> >> >> Below find the org-mime export of the org-mime worg page which will
> be
> >> >> available at http://orgmode.org/worg/org-contrib/org-mime.php.
> >> >>
> >> >> Best -- Eric
> >> >>
> >> >> General
> >> >>
> >> >> 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.
> >> >>
> >> >>   How to use it
> >> >>  Setup
> >> >>
> >> >> org-mime exposes two functions
> >> >>  `org-mime-htmlize' can be called from within a mail composition
> buffer
> >> to
> >> >> export either the entire buffer or just the active region to html,
> and
> >> embed
> >> >> the results into the buffer as a text/html mime section.
> >> >>
> >> >> 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' can be called from within an Org-mode
> >> >> buffer to export either the whole buffer or the narrowed subtree or
> >> active
> >> >> region to HTML, and open a new email buffer including the resulting
> HTML
> >> >> content as an embedded mime section.
> >> >>
> >> >> 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)))
> >> >>
> >> >>   CSS style customization
> >> >>
> >> >> 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.
> >> >>
> >> >>    - for those who use color themes with Dark backgrounds it is
> useful
> >> to
> >> >>    set a dark background for all exported code blocks and example
> >> regions. This
> >> >>    can be accomplished with the following
> >> >>
> >> >>    (add-hook 'org-mime-html-hook
> >> >>              (lambda ()
> >> >>                (org-mime-change-element-style
> >> >>                 "pre" (format "color: %s; background-color: %s;
> padding:
> >> 0.5em;"
> >> >>                               "#E6E1DC" "#232323"))))
> >> >>
> >> >>     - the following can be used to nicely offset block quotes in
> email
> >> >>    bodies
> >> >>
> >> >>    (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.
> >> >>   Credits
> >> >>
> >> >> org-mime was developed by Eric Schulte with much-appreciated help and
> >> >> discussion from everyone on the "using orgmode to send html mail<
> >> http://thread.gmane.org/gmane.emacs.orgmode/23153>"
> >> >> thread especially David Maus.
> >> >>
> >> >> "Eric Schulte" <schulte.eric@gmail.com> writes:
> >> >>
> >> >> > Carsten Dominik <carsten.dominik@gmail.com> writes:
> >> >> >
> >> >> >> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
> >> >> >>
> >> >> >>> Hi,
> >> >> >>>
> >> >> >>> It is now possible to send HTML mail directly form an org-mode
> >> buffer.
> >> >> >>>
> >> >> >>> Calling `org-mime-org-buffer-htmlize' (could probably use a
> better
> >> >> >>> name)
> >> >> >>> from inside of an org-mode buffer will use `org-export-as-html'
> to
> >> >> >>> generate HTML of the buffer (respecting regions and subtree
> >> >> >>> narrowing),
> >> >> >>> and will then package the resulting HTML with all linked images
> into
> >> a
> >> >> >>> message buffer.
> >> >> >>>
> >> >> >>> As usual thanks to Carsten's thoughtfully organized functions and
> >> >> >>> control variables this was surprisingly easy to implement.
> >> >> >>>
> >> >> >>> Cheers -- Eric
> >> >> >>>
> >> >> >>> The code is still up at http://github.com/eschulte/org-mime
> >> >> >>
> >> >> >> CONTIRB?  yes, after the release.....
> >> >> >>
> >> >> >
> >> >> > Sounds great, I'm move this into contrib then. -- Eric
> >> >> >
> >> >> >>
> >> >> >> - Carsten
> >> >> >>
> >> >> >>>
> >> >> >>> "Eric Schulte" <schulte.eric@gmail.com> writes:
> >> >> >>>
> >> >> >>>> Dan Davison <davison@stats.ox.ac.uk> writes:
> >> >> >>>>
> >> >> >>>> [...]
> >> >> >>>>
> >> >> >>>>>
> >> >> >>>>> As I understand it the code you've written is designed to be
> >> >> >>>>> called in a
> >> >> >>>>> message-mode buffer with orgstruct-mode in force. Would it make
> >> >> >>>>> sense to
> >> >> >>>>> also include in your package a complementary function, that one
> >> >> >>>>> calls in
> >> >> >>>>> an org-mode buffer? I envisage this generating the HTML,
> forming
> >> the
> >> >> >>>>> multipart email contents, and then saving it to the kill ring,
> so
> >> >> >>>>> that
> >> >> >>>>> it can be pasted into an email.
> >> >> >>>>>
> >> >> >>>>> This function would have access to the directory-name and so
> >> >> >>>>> should be
> >> >> >>>>> able to resolve relative paths. Also, there might be some other
> >> >> >>>>> advantages -- for example when exporting just a region or
> subtree,
> >> >> >>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked
> up
> >> >> >>>>> by the
> >> >> >>>>> org exporter and packaged into the HTML.
> >> >> >>>>>
> >> >> >>>>> In other words, can I use your machinery to package up the HTML
> >> >> >>>>> generated by Org's C-e dispatcher into an
> >> appropriately-constructed
> >> >> >>>>> email?
> >> >> >>>>>
> >> >> >>>>
> >> >> >>>> Hi Dan,
> >> >> >>>>
> >> >> >>>> That sounds like a good idea, I've added it to a fledgling task
> >> list
> >> >> >>>> packaged in the README at [1].  I'd say there are two options.
> >> >> >>>>
> >> >> >>>> 1) which you mentioned saving the entire exported content to the
> >> >> >>>>   kill-ring.  One problem here is that everything is still text
> and
> >> >> >>>>   pastable only *before* the mime export process, which means
> that
> >> >> >>>>   linked images wouldn't resolve after pasting into the email
> >> client.
> >> >> >>>>
> >> >> >>>> 2) having the function generate a new mail buffer containing the
> >> >> >>>>   exported content.  This buffer would need to have it's
> >> >> >>>>   `buffer-file-name' set, for images to resolve during export.
>  I'm
> >> >> >>>> not
> >> >> >>>>   sure how this should best work.
> >> >> >>>>
> >> >> >>>> Thanks -- Eric
> >> >> >>>>
> >> >> >>>> Footnotes:
> >> >> >>>> [1]  http://github.com/eschulte/org-mime
> >> >> >>>
> >> >> >>>
> >> >> >>> _______________________________________________
> >> >> >>> Emacs-orgmode mailing list
> >> >> >>> Please use `Reply All' to send replies to the list.
> >> >> >>> Emacs-orgmode@gnu.org
> >> >> >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >> >> >>
> >> >> >> - Carsten
> >> >>
> >> >> _______________________________________________
> >> >> Emacs-orgmode mailing list
> >> >> Please use `Reply All' to send replies to the list.
> >> >> Emacs-orgmode@gnu.org
> >> >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >> >>
> >> >>
> >>
>

[-- Attachment #1.2: Type: text/html, Size: 24892 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14  0:57                                                 ` Eric Schulte
  2010-04-14  1:57                                                   ` Andrew Hyatt
@ 2010-04-14  8:39                                                   ` Eric S Fraga
  2010-04-14 15:12                                                     ` Eric Schulte
  1 sibling, 1 reply; 63+ messages in thread
From: Eric S Fraga @ 2010-04-14  8:39 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

On Tue, 13 Apr 2010 18:57:07 -0600, "Eric Schulte" <schulte.eric@gmail.com> wrote:
> 
> So, for some reason the `org-mime-org-export' helper function is
> returning nil on your (and Eric's) machines.  Could you try evaluating
> (C-M-x) the following in your *scratch* buffer?
> 
> (insert (org-mime-org-export "html" "- first
> - second
> - third" (make-temp-file "quick-test")))

I get exactly the same as you do.

> to export a non-html buffer to html, or you could also try starting up
> Emacs with the -Q option, then loading org-mime.el, opening an org-mode
> file, and calling org-mime-org-buffer-htmlize, and sending an email to
> yourself.

Interesting.  This fails for me:

1. emacs -Q
2. in *scratch*: set load path appropriately, (require 'org-install), (require 'org-mime)
3. visit org test buffer
4. invoke org-mime-org-buffer-htmlize which fails with 

   org-mime-file: Symbol's function definition is void: case

   although the HTML has been created and pushed to the kill ring
   according to the *Messages* buffer.

5. so try (require 'cl)
6. try org-mime-org-buffer-htmlize again and now there is no error but
   the output is:

   ,----
   |    <#multipart type=alternative><#part type=text/plain>
   | * Testing mime in org
   | 
   |   This file will provide a simple test for the new mime encoding and
   |   exporting features in org-mode.
   | 
   |   The most interesting aspect may be the use of \(y = \sum_i^n x_i^2\)
   |   and, please, see the figure:
   | 
   |   [[./mip.png]]
   |   <#part type=text/html>nil<#/multipart>
   |   <#part type="image/png" filename="/home/ucecesf/s/test/mip.png" id="<_home_ucecesf_s_test_mip.png>">
   |   <#/part>
   `----

I hope some of this might help identify where the problem may lie?  I
can obviously send you my full org environment if you wish. I'm also
happy to debug the org-mime code directly if you give me some idea of
where to look!

Thanks,
eric

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14  1:57                                                   ` Andrew Hyatt
@ 2010-04-14 14:59                                                     ` Eric Schulte
  2010-04-14 18:00                                                       ` Andrew Hyatt
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-14 14:59 UTC (permalink / raw)
  To: Andrew Hyatt; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 807 bytes --]

Hi Andrew,

I started my emacs with the -Q option, and to my surprise I got the same
error that you have described.  I've been able to hunt down the source
of this problem, and it is an old version of org-export-as-org, which
means that you are not loading the latest version of the core org-mode,
but rather the version distributed with Emacs.

This is what happened to me when I started with the -Q option and simple
required org-install without first adding the path to the newer version
of org-mode to my load path.

An easy way to verify that this is the case is to call describe-function
with C-h f org-export-as-org, then jump to the source-code of the
function by pressing enter on the linked function name, and jumping down
to the last 5 lines of the function definition.  If they don't look like


[-- Attachment #2.1: Type: text/plain, Size: 235 bytes --]

#+begin_src emacs-lisp
  (if (equal to-buffer 'string)
            (progn (setq str-ret (buffer-string))
                   (kill-buffer (current-buffer))
                   str-ret)
          (kill-buffer (current-buffer)))
#+end_src

[-- Attachment #2.2: Type: text/html, Size: 891 bytes --]

[-- Attachment #3: Type: text/plain, Size: 18450 bytes --]


then you are still using an old version of Org-mode.  Hopefully once you
are sync'd to the head of the org-mode repository this error will be
fixed.

Hope this helps, Best -- Eric

Andrew Hyatt <ahyatt@gmail.com> writes:

> I do get the same result you do.  Hopefully, I'll have some time tomorrow to
> look into the issue.  RIght now, though, my problem is not the nil, but the
> error I reported in my previous email.
>
> On Tue, Apr 13, 2010 at 8:57 PM, Eric Schulte <schulte.eric@gmail.com>wrote:
>
>> So, for some reason the `org-mime-org-export' helper function is
>> returning nil on your (and Eric's) machines.  Could you try evaluating
>> (C-M-x) the following in your *scratch* buffer?
>>
>> (insert (org-mime-org-export "html" "- first
>> - second
>> - third" (make-temp-file "quick-test")))
>>
>> When I execute the above it inserts the following into the scratch
>> buffer
>>
>> <ul>
>> <li>
>> first
>> </li>
>> <li>
>> second
>> </li>
>> <li>
>> third
>> </li>
>> </ul>
>>
>> If instead you get an error, or it inserts nil, then it means that our
>> systems are somehow different with respect to that function, which is a
>> slight alteration of `org-run-like-in-org-mode'.
>>
>> At that point you could try using something like
>>
>> (org-run-like-in-org-mode 'org-export-as-html)
>>
>> to export a non-html buffer to html, or you could also try starting up
>> Emacs with the -Q option, then loading org-mime.el, opening an org-mode
>> file, and calling org-mime-org-buffer-htmlize, and sending an email to
>> yourself.
>>
>> Sorry I can't be of more help, I'm really mystified as to how this
>> function could be returning nil.
>>
>> Best -- Eric
>>
>> Andrew Hyatt <ahyatt@gmail.com> writes:
>>
>> > Thanks for the response.  I upgraded, now I get a
>> >
>> > Debugger entered--Lisp error: (wrong-type-argument arrayp t)
>> >  substring(t 33)
>> >  (progn (insert org-mime-default-header) (insert body) (write-file
>> tmp-file)
>> > (org-load-modules-maybe) (unless org-local-vars (setq org-local-vars
>> ...))
>> > (substring (eval ...) (if ... ... 0)))
>> >  (unwind-protect (progn (insert org-mime-default-header) (insert body)
>> > (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
>> ...)
>> > (substring ... ...)) (and (buffer-name temp-buffer) (kill-buffer
>> > temp-buffer)))
>> >  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...
>> > ... ... ... ... ...) (and ... ...)))
>> >  (with-current-buffer temp-buffer (unwind-protect (progn ... ... ... ...
>> ...
>> > ...) (and ... ...)))
>> >  (let ((temp-buffer ...)) (with-current-buffer temp-buffer
>> (unwind-protect
>> > ... ...)))
>> >  (with-temp-buffer (insert org-mime-default-header) (insert body)
>> > (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
>> (setq
>> > org-local-vars ...)) (substring (eval ...) (if ... ... 0)))
>> >  (save-excursion (with-temp-buffer (insert org-mime-default-header)
>> (insert
>> > body) (write-file tmp-file) (org-load-modules-maybe) (unless
>> org-local-vars
>> > ...) (substring ... ...)))
>> >  org-mime-org-export("org" #("\nHTML test\n\n~foo~\n=bar=\n_baz_\n\n| 1 |
>> 2
>> > |\n| a | b |\n" 0 1 (fontified t) 1 11 (fontified t) 11 12 (fontified t)
>> 12
>> > 18 (fontified t) 18 24 (fontified t) 24 30 (fontified t) 30 31 (fontified
>> t)
>> > 31 40 (fontified t face (gnus-cite-1 message-cited-text)) 40 41
>> (fontified
>> > t) 41 50 (fontified t face (gnus-cite-1 message-cited-text)) 50 51
>> > (fontified t)) "/tmp/mail2522ZvL")
>> >  (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
>> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading nil)
>> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
>> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...) (html
>> > ...)) (delete-region html-start html-end) (save-excursion (goto-char
>> > html-start) (insert ... ...)))
>> >  org-mime-htmlize(nil)
>> >  call-interactively(org-mime-htmlize record nil)
>> >
>> > I tried this with orgstruct-mode off and on, but it was the same error
>> > either way.  Earlier, before I got the latest version, I tried with
>> > orgstruct-mode on, and it successfull htmlized my mail. But, when I
>> received
>> > it, the mail only contained the word "nil".
>> >
>> > On Mon, Apr 12, 2010 at 1:22 PM, Eric Schulte <schulte.eric@gmail.com
>> >wrote:
>> >
>> >> Hi Andrew,
>> >>
>> >> Thanks for the report.  My guess is that somehow the call to
>> >> org-export-as-html is erroring out because some org-mode variables
>> >> aren't being set, maybe you don't have orgstruct-mode as a minor-mode in
>> >> your email composition -- not that it's required, but that could be the
>> >> difference between our setups which is causing you to see the bug and
>> >> not me.
>> >>
>> >> I've changed the `org-mime-org-export' so it more closely mimics the
>> >> `org-run-like-in-org-mode' wrapping function, which should hopefully fix
>> >> this problem.  Please let me know either way, and if the problem
>> >> persists we can try to figure out exactly which variable isn't being
>> >> initialized.
>> >>
>> >> Thanks for the report! -- Eric
>> >>
>> >> Andrew Hyatt <ahyatt@gmail.com> writes:
>> >>
>> >> > This looks great.  However, I get an error on my test mail:
>> >> >
>> >> > This is should be HTML mode.
>> >> >
>> >> > ~foo~
>> >> > =bar=
>> >> > _baz_
>> >> >
>> >> > | Table | A |
>> >> > | 1     | 2 |
>> >> >
>> >> > On calling org-mime-htmlize
>> >> >
>> >> > Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>> >> >   string-match(nil #("This is should be HTML mode." 0 28 (fontified
>> t)))
>> >> >   byte-code("\304\211. \305\n \"\203A
>> >> >   org-html-handle-time-stamps(#("This is should be HTML mode." 0 28
>> >> > (fontified t)))
>> >> >   byte-code(" \203.
>> >> >   org-export-as-html(nil nil nil string t)
>> >> >   (let nil (org-export-as-html nil nil nil (quote string) t))
>> >> >   eval((let nil (org-export-as-html nil nil nil (quote string) t)))
>> >> >   (progn (insert org-mime-default-header) (insert body) (write-file
>> >> > tmp-file) (eval (list ... org-local-vars ...)))
>> >> >   (unwind-protect (progn (insert org-mime-default-header) (insert
>> body)
>> >> > (write-file tmp-file) (eval ...)) (and (buffer-name temp-buffer)
>> >> > (kill-buffer temp-buffer)))
>> >> >   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
>> >> ...
>> >> > ... ... ...) (and ... ...)))
>> >> >   (with-current-buffer temp-buffer (unwind-protect (progn ... ... ...
>> >> ...)
>> >> > (and ... ...)))
>> >> >   (let ((temp-buffer ...)) (with-current-buffer temp-buffer
>> >> (unwind-protect
>> >> > ... ...)))
>> >> >   (with-temp-buffer (insert org-mime-default-header) (insert body)
>> >> > (write-file tmp-file) (eval (list ... org-local-vars ...)))
>> >> >   (save-excursion (with-temp-buffer (insert org-mime-default-header)
>> >> (insert
>> >> > body) (write-file tmp-file) (eval ...)))
>> >> >   org-mime-org-export("html" #("\nThis is should be HTML
>> >> > mode.\n\n~foo~\n=bar=\n_baz_\n\n| Table | A |\n| 1     | 2 | \n\n--
>> \n" 0
>> >> 1
>> >> > (fontified t) 1 42 (fontified t) 42 43 (fontified t) 43 44
>> (article-type
>> >> > emphasis fontified t) 44 47 (fontified t) 47 48 (article-type emphasis
>> >> > fontified t) 48 50 (fontified t) 50 63 (fontified t face (gnus-cite-1
>> >> > message-cited-text)) 63 64 (fontified t) 64 78 (fontified t face
>> >> > (gnus-cite-1 message-cited-text)) 78 79 (fontified t rear-nonsticky t)
>> 79
>> >> 80
>> >> > (fontified t) 80 84 (fontified t)) "/tmp/mail2522NRw")
>> >> >   (org-mime-replace-images (org-mime-org-export "html" raw-body
>> tmp-file)
>> >> > tmp-file)
>> >> >   (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
>> >> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading
>> nil)
>> >> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
>> >> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...)
>> (html
>> >> > ...)) (delete-region html-start html-end) (save-excursion (goto-char
>> >> > html-start) (insert ... ...)))
>> >> >   org-mime-htmlize(nil)
>> >> >
>> >> >
>> >> > On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com
>> >> >wrote:
>> >> >
>> >> >> Announcing the addition of org-mime to the contrib directory of
>> Org-mode
>> >> >>
>> >> >> this allows sending HTML email using org-mode including...
>> >> >>
>> >> >>
>> >> >>    - *tables*   colname onecolname two  11 24 39
>> >> >>    - *inline images* including latex equations [image: $f(n) = n +
>> >> >>    \frac{1}{n} \int_{0}^{n}{d_x f(x) + f(n - x)}$] and the results of
>> >> >>    ditaa blocks, etc…
>> >> >>
>> >> >> [image: blue.png]
>> >> >>
>> >> >>    - *blockquotes*
>> >> >>
>> >> >>    HTML e-mail is the use of a subset of HTML (often ill-defined) to
>> >> >>    provide formatting and semantic markup capabilities in e-mail that
>> >> are not
>> >> >>    available with plain text. – wikipedia
>> >> >>
>> >> >>     - fontified *code blocks* (shown below)
>> >> >>    - and *HTML character* conversion, like ∀ character c s.t. ∃ h ∈
>> >> *HTML
>> >> >>    characters* and c ≡ h, org-html-export of c results in h
>> >> >>
>> >> >>
>> >> >>
>> >> >> The original org-mode formatted plain text is included as a
>> text/plain
>> >> >> mime alternative to the generated html.
>> >> >>
>> >> >> Below find the org-mime export of the org-mime worg page which will
>> be
>> >> >> available at http://orgmode.org/worg/org-contrib/org-mime.php.
>> >> >>
>> >> >> Best -- Eric
>> >> >>
>> >> >> General
>> >> >>
>> >> >> 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.
>> >> >>
>> >> >>   How to use it
>> >> >>  Setup
>> >> >>
>> >> >> org-mime exposes two functions
>> >> >>  `org-mime-htmlize' can be called from within a mail composition
>> buffer
>> >> to
>> >> >> export either the entire buffer or just the active region to html,
>> and
>> >> embed
>> >> >> the results into the buffer as a text/html mime section.
>> >> >>
>> >> >> 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' can be called from within an Org-mode
>> >> >> buffer to export either the whole buffer or the narrowed subtree or
>> >> active
>> >> >> region to HTML, and open a new email buffer including the resulting
>> HTML
>> >> >> content as an embedded mime section.
>> >> >>
>> >> >> 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)))
>> >> >>
>> >> >>   CSS style customization
>> >> >>
>> >> >> 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.
>> >> >>
>> >> >>    - for those who use color themes with Dark backgrounds it is
>> useful
>> >> to
>> >> >>    set a dark background for all exported code blocks and example
>> >> regions. This
>> >> >>    can be accomplished with the following
>> >> >>
>> >> >>    (add-hook 'org-mime-html-hook
>> >> >>              (lambda ()
>> >> >>                (org-mime-change-element-style
>> >> >>                 "pre" (format "color: %s; background-color: %s;
>> padding:
>> >> 0.5em;"
>> >> >>                               "#E6E1DC" "#232323"))))
>> >> >>
>> >> >>     - the following can be used to nicely offset block quotes in
>> email
>> >> >>    bodies
>> >> >>
>> >> >>    (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.
>> >> >>   Credits
>> >> >>
>> >> >> org-mime was developed by Eric Schulte with much-appreciated help and
>> >> >> discussion from everyone on the "using orgmode to send html mail<
>> >> http://thread.gmane.org/gmane.emacs.orgmode/23153>"
>> >> >> thread especially David Maus.
>> >> >>
>> >> >> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> >> >>
>> >> >> > Carsten Dominik <carsten.dominik@gmail.com> writes:
>> >> >> >
>> >> >> >> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
>> >> >> >>
>> >> >> >>> Hi,
>> >> >> >>>
>> >> >> >>> It is now possible to send HTML mail directly form an org-mode
>> >> buffer.
>> >> >> >>>
>> >> >> >>> Calling `org-mime-org-buffer-htmlize' (could probably use a
>> better
>> >> >> >>> name)
>> >> >> >>> from inside of an org-mode buffer will use `org-export-as-html'
>> to
>> >> >> >>> generate HTML of the buffer (respecting regions and subtree
>> >> >> >>> narrowing),
>> >> >> >>> and will then package the resulting HTML with all linked images
>> into
>> >> a
>> >> >> >>> message buffer.
>> >> >> >>>
>> >> >> >>> As usual thanks to Carsten's thoughtfully organized functions and
>> >> >> >>> control variables this was surprisingly easy to implement.
>> >> >> >>>
>> >> >> >>> Cheers -- Eric
>> >> >> >>>
>> >> >> >>> The code is still up at http://github.com/eschulte/org-mime
>> >> >> >>
>> >> >> >> CONTIRB?  yes, after the release.....
>> >> >> >>
>> >> >> >
>> >> >> > Sounds great, I'm move this into contrib then. -- Eric
>> >> >> >
>> >> >> >>
>> >> >> >> - Carsten
>> >> >> >>
>> >> >> >>>
>> >> >> >>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> >> >> >>>
>> >> >> >>>> Dan Davison <davison@stats.ox.ac.uk> writes:
>> >> >> >>>>
>> >> >> >>>> [...]
>> >> >> >>>>
>> >> >> >>>>>
>> >> >> >>>>> As I understand it the code you've written is designed to be
>> >> >> >>>>> called in a
>> >> >> >>>>> message-mode buffer with orgstruct-mode in force. Would it make
>> >> >> >>>>> sense to
>> >> >> >>>>> also include in your package a complementary function, that one
>> >> >> >>>>> calls in
>> >> >> >>>>> an org-mode buffer? I envisage this generating the HTML,
>> forming
>> >> the
>> >> >> >>>>> multipart email contents, and then saving it to the kill ring,
>> so
>> >> >> >>>>> that
>> >> >> >>>>> it can be pasted into an email.
>> >> >> >>>>>
>> >> >> >>>>> This function would have access to the directory-name and so
>> >> >> >>>>> should be
>> >> >> >>>>> able to resolve relative paths. Also, there might be some other
>> >> >> >>>>> advantages -- for example when exporting just a region or
>> subtree,
>> >> >> >>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are picked
>> up
>> >> >> >>>>> by the
>> >> >> >>>>> org exporter and packaged into the HTML.
>> >> >> >>>>>
>> >> >> >>>>> In other words, can I use your machinery to package up the HTML
>> >> >> >>>>> generated by Org's C-e dispatcher into an
>> >> appropriately-constructed
>> >> >> >>>>> email?
>> >> >> >>>>>
>> >> >> >>>>
>> >> >> >>>> Hi Dan,
>> >> >> >>>>
>> >> >> >>>> That sounds like a good idea, I've added it to a fledgling task
>> >> list
>> >> >> >>>> packaged in the README at [1].  I'd say there are two options.
>> >> >> >>>>
>> >> >> >>>> 1) which you mentioned saving the entire exported content to the
>> >> >> >>>>   kill-ring.  One problem here is that everything is still text
>> and
>> >> >> >>>>   pastable only *before* the mime export process, which means
>> that
>> >> >> >>>>   linked images wouldn't resolve after pasting into the email
>> >> client.
>> >> >> >>>>
>> >> >> >>>> 2) having the function generate a new mail buffer containing the
>> >> >> >>>>   exported content.  This buffer would need to have it's
>> >> >> >>>>   `buffer-file-name' set, for images to resolve during export.
>>  I'm
>> >> >> >>>> not
>> >> >> >>>>   sure how this should best work.
>> >> >> >>>>
>> >> >> >>>> Thanks -- Eric
>> >> >> >>>>
>> >> >> >>>> Footnotes:
>> >> >> >>>> [1]  http://github.com/eschulte/org-mime
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> _______________________________________________
>> >> >> >>> Emacs-orgmode mailing list
>> >> >> >>> Please use `Reply All' to send replies to the list.
>> >> >> >>> Emacs-orgmode@gnu.org
>> >> >> >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>> >> >> >>
>> >> >> >> - Carsten
>> >> >>
>> >> >> _______________________________________________
>> >> >> Emacs-orgmode mailing list
>> >> >> Please use `Reply All' to send replies to the list.
>> >> >> Emacs-orgmode@gnu.org
>> >> >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>> >> >>
>> >> >>
>> >>
>>

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14  8:39                                                   ` Eric S Fraga
@ 2010-04-14 15:12                                                     ` Eric Schulte
  2010-04-14 19:38                                                       ` Eric S Fraga
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-14 15:12 UTC (permalink / raw)
  To: e.fraga; +Cc: emacs-orgmode

Hi Eric,

Thanks for the explicit feedback, it's very helpful.

Eric S Fraga <ucecesf@ucl.ac.uk> writes:

[...]

> Interesting.  This fails for me:
>
> 1. emacs -Q
> 2. in *scratch*: set load path appropriately, (require 'org-install), (require 'org-mime)
> 3. visit org test buffer
> 4. invoke org-mime-org-buffer-htmlize which fails with 
>
>    org-mime-file: Symbol's function definition is void: case
>
>    although the HTML has been created and pushed to the kill ring
>    according to the *Messages* buffer.
>
> 5. so try (require 'cl)

Ah, thanks, I've added (require 'cl) to org-mime.el

> 
> 6. try org-mime-org-buffer-htmlize again and now there is no error but
> the output is:
>

I see the problem here, I've just pushed up a change to org-mime.el
which will ensure that your html mime alternative will no longer be nil.
However, you will continue to have "t" as your text alternative until
you ensure that you are loading the latest version of the core of
org-mode, as described in my recent email to Andrew.

Please let me know how this goes.

Best -- Eric

>
>    ,----
>    |    <#multipart type=alternative><#part type=text/plain>
>    | * Testing mime in org
>    | 
>    |   This file will provide a simple test for the new mime encoding and
>    |   exporting features in org-mode.
>    | 
>    |   The most interesting aspect may be the use of \(y = \sum_i^n x_i^2\)
>    |   and, please, see the figure:
>    | 
>    |   [[./mip.png]]
>    |   <#part type=text/html>nil<#/multipart>
>    |   <#part type="image/png" filename="/home/ucecesf/s/test/mip.png" id="<_home_ucecesf_s_test_mip.png>">
>    |   <#/part>
>    `----
>
> I hope some of this might help identify where the problem may lie?  I
> can obviously send you my full org environment if you wish. I'm also
> happy to debug the org-mime code directly if you give me some idea of
> where to look!
>
> Thanks,
> eric

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14 14:59                                                     ` Eric Schulte
@ 2010-04-14 18:00                                                       ` Andrew Hyatt
  2010-04-14 19:26                                                         ` Bernt Hansen
  0 siblings, 1 reply; 63+ messages in thread
From: Andrew Hyatt @ 2010-04-14 18:00 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 21001 bytes --]

Thanks! I  finally got it to work. I actually did have the latest code, but
my issue was that when I upgraded to the new org, I forgot to byte-compile
before I did M-x org-reload.

After I got your latest code, it all works now.  I'm looking forward to
using it!

On Wed, Apr 14, 2010 at 10:59 AM, Eric Schulte <schulte.eric@gmail.com>wrote:

> Hi Andrew,
>
> I started my emacs with the -Q option, and to my surprise I got the same
> error that you have described.  I've been able to hunt down the source
> of this problem, and it is an old version of org-export-as-org, which
> means that you are not loading the latest version of the core org-mode,
> but rather the version distributed with Emacs.
>
> This is what happened to me when I started with the -Q option and simple
> required org-install without first adding the path to the newer version
> of org-mode to my load path.
>
> An easy way to verify that this is the case is to call describe-function
> with C-h f org-export-as-org, then jump to the source-code of the
> function by pressing enter on the linked function name, and jumping down
> to the last 5 lines of the function definition.  If they don't look like
>
>
> (if (equal to-buffer 'string)
>           (progn (setq str-ret (buffer-string))
>                  (kill-buffer (current-buffer))
>                  str-ret)
>         (kill-buffer (current-buffer)))
>
>
>
> then you are still using an old version of Org-mode.  Hopefully once you
> are sync'd to the head of the org-mode repository this error will be
> fixed.
>
> Hope this helps, Best -- Eric
>
> Andrew Hyatt <ahyatt@gmail.com> writes:
>
> > I do get the same result you do.  Hopefully, I'll have some time tomorrow
> to
> > look into the issue.  RIght now, though, my problem is not the nil, but
> the
> > error I reported in my previous email.
> >
> > On Tue, Apr 13, 2010 at 8:57 PM, Eric Schulte <schulte.eric@gmail.com
> >wrote:
> >
> >> So, for some reason the `org-mime-org-export' helper function is
> >> returning nil on your (and Eric's) machines.  Could you try evaluating
> >> (C-M-x) the following in your *scratch* buffer?
> >>
> >> (insert (org-mime-org-export "html" "- first
> >> - second
> >> - third" (make-temp-file "quick-test")))
> >>
> >> When I execute the above it inserts the following into the scratch
> >> buffer
> >>
> >> <ul>
> >> <li>
> >> first
> >> </li>
> >> <li>
> >> second
> >> </li>
> >> <li>
> >> third
> >> </li>
> >> </ul>
> >>
> >> If instead you get an error, or it inserts nil, then it means that our
> >> systems are somehow different with respect to that function, which is a
> >> slight alteration of `org-run-like-in-org-mode'.
> >>
> >> At that point you could try using something like
> >>
> >> (org-run-like-in-org-mode 'org-export-as-html)
> >>
> >> to export a non-html buffer to html, or you could also try starting up
> >> Emacs with the -Q option, then loading org-mime.el, opening an org-mode
> >> file, and calling org-mime-org-buffer-htmlize, and sending an email to
> >> yourself.
> >>
> >> Sorry I can't be of more help, I'm really mystified as to how this
> >> function could be returning nil.
> >>
> >> Best -- Eric
> >>
> >> Andrew Hyatt <ahyatt@gmail.com> writes:
> >>
> >> > Thanks for the response.  I upgraded, now I get a
> >> >
> >> > Debugger entered--Lisp error: (wrong-type-argument arrayp t)
> >> >  substring(t 33)
> >> >  (progn (insert org-mime-default-header) (insert body) (write-file
> >> tmp-file)
> >> > (org-load-modules-maybe) (unless org-local-vars (setq org-local-vars
> >> ...))
> >> > (substring (eval ...) (if ... ... 0)))
> >> >  (unwind-protect (progn (insert org-mime-default-header) (insert body)
> >> > (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
> >> ...)
> >> > (substring ... ...)) (and (buffer-name temp-buffer) (kill-buffer
> >> > temp-buffer)))
> >> >  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
> ...
> >> > ... ... ... ... ...) (and ... ...)))
> >> >  (with-current-buffer temp-buffer (unwind-protect (progn ... ... ...
> ...
> >> ...
> >> > ...) (and ... ...)))
> >> >  (let ((temp-buffer ...)) (with-current-buffer temp-buffer
> >> (unwind-protect
> >> > ... ...)))
> >> >  (with-temp-buffer (insert org-mime-default-header) (insert body)
> >> > (write-file tmp-file) (org-load-modules-maybe) (unless org-local-vars
> >> (setq
> >> > org-local-vars ...)) (substring (eval ...) (if ... ... 0)))
> >> >  (save-excursion (with-temp-buffer (insert org-mime-default-header)
> >> (insert
> >> > body) (write-file tmp-file) (org-load-modules-maybe) (unless
> >> org-local-vars
> >> > ...) (substring ... ...)))
> >> >  org-mime-org-export("org" #("\nHTML test\n\n~foo~\n=bar=\n_baz_\n\n|
> 1 |
> >> 2
> >> > |\n| a | b |\n" 0 1 (fontified t) 1 11 (fontified t) 11 12 (fontified
> t)
> >> 12
> >> > 18 (fontified t) 18 24 (fontified t) 24 30 (fontified t) 30 31
> (fontified
> >> t)
> >> > 31 40 (fontified t face (gnus-cite-1 message-cited-text)) 40 41
> >> (fontified
> >> > t) 41 50 (fontified t face (gnus-cite-1 message-cited-text)) 50 51
> >> > (fontified t)) "/tmp/mail2522ZvL")
> >> >  (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body ...)
> >> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading
> nil)
> >> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
> >> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...)
> (html
> >> > ...)) (delete-region html-start html-end) (save-excursion (goto-char
> >> > html-start) (insert ... ...)))
> >> >  org-mime-htmlize(nil)
> >> >  call-interactively(org-mime-htmlize record nil)
> >> >
> >> > I tried this with orgstruct-mode off and on, but it was the same error
> >> > either way.  Earlier, before I got the latest version, I tried with
> >> > orgstruct-mode on, and it successfull htmlized my mail. But, when I
> >> received
> >> > it, the mail only contained the word "nil".
> >> >
> >> > On Mon, Apr 12, 2010 at 1:22 PM, Eric Schulte <schulte.eric@gmail.com
> >> >wrote:
> >> >
> >> >> Hi Andrew,
> >> >>
> >> >> Thanks for the report.  My guess is that somehow the call to
> >> >> org-export-as-html is erroring out because some org-mode variables
> >> >> aren't being set, maybe you don't have orgstruct-mode as a minor-mode
> in
> >> >> your email composition -- not that it's required, but that could be
> the
> >> >> difference between our setups which is causing you to see the bug and
> >> >> not me.
> >> >>
> >> >> I've changed the `org-mime-org-export' so it more closely mimics the
> >> >> `org-run-like-in-org-mode' wrapping function, which should hopefully
> fix
> >> >> this problem.  Please let me know either way, and if the problem
> >> >> persists we can try to figure out exactly which variable isn't being
> >> >> initialized.
> >> >>
> >> >> Thanks for the report! -- Eric
> >> >>
> >> >> Andrew Hyatt <ahyatt@gmail.com> writes:
> >> >>
> >> >> > This looks great.  However, I get an error on my test mail:
> >> >> >
> >> >> > This is should be HTML mode.
> >> >> >
> >> >> > ~foo~
> >> >> > =bar=
> >> >> > _baz_
> >> >> >
> >> >> > | Table | A |
> >> >> > | 1     | 2 |
> >> >> >
> >> >> > On calling org-mime-htmlize
> >> >> >
> >> >> > Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> >> >> >   string-match(nil #("This is should be HTML mode." 0 28 (fontified
> >> t)))
> >> >> >   byte-code("\304\211. \305\n \"\203A
> >> >> >   org-html-handle-time-stamps(#("This is should be HTML mode." 0 28
> >> >> > (fontified t)))
> >> >> >   byte-code(" \203.
> >> >> >   org-export-as-html(nil nil nil string t)
> >> >> >   (let nil (org-export-as-html nil nil nil (quote string) t))
> >> >> >   eval((let nil (org-export-as-html nil nil nil (quote string) t)))
> >> >> >   (progn (insert org-mime-default-header) (insert body) (write-file
> >> >> > tmp-file) (eval (list ... org-local-vars ...)))
> >> >> >   (unwind-protect (progn (insert org-mime-default-header) (insert
> >> body)
> >> >> > (write-file tmp-file) (eval ...)) (and (buffer-name temp-buffer)
> >> >> > (kill-buffer temp-buffer)))
> >> >> >   (save-current-buffer (set-buffer temp-buffer) (unwind-protect
> (progn
> >> >> ...
> >> >> > ... ... ...) (and ... ...)))
> >> >> >   (with-current-buffer temp-buffer (unwind-protect (progn ... ...
> ...
> >> >> ...)
> >> >> > (and ... ...)))
> >> >> >   (let ((temp-buffer ...)) (with-current-buffer temp-buffer
> >> >> (unwind-protect
> >> >> > ... ...)))
> >> >> >   (with-temp-buffer (insert org-mime-default-header) (insert body)
> >> >> > (write-file tmp-file) (eval (list ... org-local-vars ...)))
> >> >> >   (save-excursion (with-temp-buffer (insert
> org-mime-default-header)
> >> >> (insert
> >> >> > body) (write-file tmp-file) (eval ...)))
> >> >> >   org-mime-org-export("html" #("\nThis is should be HTML
> >> >> > mode.\n\n~foo~\n=bar=\n_baz_\n\n| Table | A |\n| 1     | 2 | \n\n--
> >> \n" 0
> >> >> 1
> >> >> > (fontified t) 1 42 (fontified t) 42 43 (fontified t) 43 44
> >> (article-type
> >> >> > emphasis fontified t) 44 47 (fontified t) 47 48 (article-type
> emphasis
> >> >> > fontified t) 48 50 (fontified t) 50 63 (fontified t face
> (gnus-cite-1
> >> >> > message-cited-text)) 63 64 (fontified t) 64 78 (fontified t face
> >> >> > (gnus-cite-1 message-cited-text)) 78 79 (fontified t rear-nonsticky
> t)
> >> 79
> >> >> 80
> >> >> > (fontified t) 80 84 (fontified t)) "/tmp/mail2522NRw")
> >> >> >   (org-mime-replace-images (org-mime-org-export "html" raw-body
> >> tmp-file)
> >> >> > tmp-file)
> >> >> >   (let* ((region-p ...) (html-start ...) (html-end ...) (raw-body
> ...)
> >> >> > (tmp-file ...) (body ...) (org-export-skip-text-before-1st-heading
> >> nil)
> >> >> > (org-export-htmlize-output-type ...) (org-export-preserve-breaks
> >> >> > org-mime-preserve-breaks) (html-and-images ...) (html-images ...)
> >> (html
> >> >> > ...)) (delete-region html-start html-end) (save-excursion
> (goto-char
> >> >> > html-start) (insert ... ...)))
> >> >> >   org-mime-htmlize(nil)
> >> >> >
> >> >> >
> >> >> > On Fri, Apr 9, 2010 at 12:41 PM, Eric Schulte <
> schulte.eric@gmail.com
> >> >> >wrote:
> >> >> >
> >> >> >> Announcing the addition of org-mime to the contrib directory of
> >> Org-mode
> >> >> >>
> >> >> >> this allows sending HTML email using org-mode including...
> >> >> >>
> >> >> >>
> >> >> >>    - *tables*   colname onecolname two  11 24 39
> >> >> >>    - *inline images* including latex equations [image: $f(n) = n +
> >> >> >>    \frac{1}{n} \int_{0}^{n}{d_x f(x) + f(n - x)}$] and the results
> of
> >> >> >>    ditaa blocks, etc…
> >> >> >>
> >> >> >> [image: blue.png]
> >> >> >>
> >> >> >>    - *blockquotes*
> >> >> >>
> >> >> >>    HTML e-mail is the use of a subset of HTML (often ill-defined)
> to
> >> >> >>    provide formatting and semantic markup capabilities in e-mail
> that
> >> >> are not
> >> >> >>    available with plain text. – wikipedia
> >> >> >>
> >> >> >>     - fontified *code blocks* (shown below)
> >> >> >>    - and *HTML character* conversion, like ∀ character c s.t. ∃ h
> ∈
> >> >> *HTML
> >> >> >>    characters* and c ≡ h, org-html-export of c results in h
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> The original org-mode formatted plain text is included as a
> >> text/plain
> >> >> >> mime alternative to the generated html.
> >> >> >>
> >> >> >> Below find the org-mime export of the org-mime worg page which
> will
> >> be
> >> >> >> available at http://orgmode.org/worg/org-contrib/org-mime.php.
> >> >> >>
> >> >> >> Best -- Eric
> >> >> >>
> >> >> >> General
> >> >> >>
> >> >> >> 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.
> >> >> >>
> >> >> >>   How to use it
> >> >> >>  Setup
> >> >> >>
> >> >> >> org-mime exposes two functions
> >> >> >>  `org-mime-htmlize' can be called from within a mail composition
> >> buffer
> >> >> to
> >> >> >> export either the entire buffer or just the active region to html,
> >> and
> >> >> embed
> >> >> >> the results into the buffer as a text/html mime section.
> >> >> >>
> >> >> >> 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' can be called from within an
> Org-mode
> >> >> >> buffer to export either the whole buffer or the narrowed subtree
> or
> >> >> active
> >> >> >> region to HTML, and open a new email buffer including the
> resulting
> >> HTML
> >> >> >> content as an embedded mime section.
> >> >> >>
> >> >> >> 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)))
> >> >> >>
> >> >> >>   CSS style customization
> >> >> >>
> >> >> >> 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.
> >> >> >>
> >> >> >>    - for those who use color themes with Dark backgrounds it is
> >> useful
> >> >> to
> >> >> >>    set a dark background for all exported code blocks and example
> >> >> regions. This
> >> >> >>    can be accomplished with the following
> >> >> >>
> >> >> >>    (add-hook 'org-mime-html-hook
> >> >> >>              (lambda ()
> >> >> >>                (org-mime-change-element-style
> >> >> >>                 "pre" (format "color: %s; background-color: %s;
> >> padding:
> >> >> 0.5em;"
> >> >> >>                               "#E6E1DC" "#232323"))))
> >> >> >>
> >> >> >>     - the following can be used to nicely offset block quotes in
> >> email
> >> >> >>    bodies
> >> >> >>
> >> >> >>    (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.
> >> >> >>   Credits
> >> >> >>
> >> >> >> org-mime was developed by Eric Schulte with much-appreciated help
> and
> >> >> >> discussion from everyone on the "using orgmode to send html mail<
> >> >> http://thread.gmane.org/gmane.emacs.orgmode/23153>"
> >> >> >> thread especially David Maus.
> >> >> >>
> >> >> >> "Eric Schulte" <schulte.eric@gmail.com> writes:
> >> >> >>
> >> >> >> > Carsten Dominik <carsten.dominik@gmail.com> writes:
> >> >> >> >
> >> >> >> >> On Apr 5, 2010, at 7:39 AM, Eric Schulte wrote:
> >> >> >> >>
> >> >> >> >>> Hi,
> >> >> >> >>>
> >> >> >> >>> It is now possible to send HTML mail directly form an org-mode
> >> >> buffer.
> >> >> >> >>>
> >> >> >> >>> Calling `org-mime-org-buffer-htmlize' (could probably use a
> >> better
> >> >> >> >>> name)
> >> >> >> >>> from inside of an org-mode buffer will use
> `org-export-as-html'
> >> to
> >> >> >> >>> generate HTML of the buffer (respecting regions and subtree
> >> >> >> >>> narrowing),
> >> >> >> >>> and will then package the resulting HTML with all linked
> images
> >> into
> >> >> a
> >> >> >> >>> message buffer.
> >> >> >> >>>
> >> >> >> >>> As usual thanks to Carsten's thoughtfully organized functions
> and
> >> >> >> >>> control variables this was surprisingly easy to implement.
> >> >> >> >>>
> >> >> >> >>> Cheers -- Eric
> >> >> >> >>>
> >> >> >> >>> The code is still up at http://github.com/eschulte/org-mime
> >> >> >> >>
> >> >> >> >> CONTIRB?  yes, after the release.....
> >> >> >> >>
> >> >> >> >
> >> >> >> > Sounds great, I'm move this into contrib then. -- Eric
> >> >> >> >
> >> >> >> >>
> >> >> >> >> - Carsten
> >> >> >> >>
> >> >> >> >>>
> >> >> >> >>> "Eric Schulte" <schulte.eric@gmail.com> writes:
> >> >> >> >>>
> >> >> >> >>>> Dan Davison <davison@stats.ox.ac.uk> writes:
> >> >> >> >>>>
> >> >> >> >>>> [...]
> >> >> >> >>>>
> >> >> >> >>>>>
> >> >> >> >>>>> As I understand it the code you've written is designed to be
> >> >> >> >>>>> called in a
> >> >> >> >>>>> message-mode buffer with orgstruct-mode in force. Would it
> make
> >> >> >> >>>>> sense to
> >> >> >> >>>>> also include in your package a complementary function, that
> one
> >> >> >> >>>>> calls in
> >> >> >> >>>>> an org-mode buffer? I envisage this generating the HTML,
> >> forming
> >> >> the
> >> >> >> >>>>> multipart email contents, and then saving it to the kill
> ring,
> >> so
> >> >> >> >>>>> that
> >> >> >> >>>>> it can be pasted into an email.
> >> >> >> >>>>>
> >> >> >> >>>>> This function would have access to the directory-name and so
> >> >> >> >>>>> should be
> >> >> >> >>>>> able to resolve relative paths. Also, there might be some
> other
> >> >> >> >>>>> advantages -- for example when exporting just a region or
> >> subtree,
> >> >> >> >>>>> buffer-wide properties such as #+TITLE and #+AUTHOR are
> picked
> >> up
> >> >> >> >>>>> by the
> >> >> >> >>>>> org exporter and packaged into the HTML.
> >> >> >> >>>>>
> >> >> >> >>>>> In other words, can I use your machinery to package up the
> HTML
> >> >> >> >>>>> generated by Org's C-e dispatcher into an
> >> >> appropriately-constructed
> >> >> >> >>>>> email?
> >> >> >> >>>>>
> >> >> >> >>>>
> >> >> >> >>>> Hi Dan,
> >> >> >> >>>>
> >> >> >> >>>> That sounds like a good idea, I've added it to a fledgling
> task
> >> >> list
> >> >> >> >>>> packaged in the README at [1].  I'd say there are two
> options.
> >> >> >> >>>>
> >> >> >> >>>> 1) which you mentioned saving the entire exported content to
> the
> >> >> >> >>>>   kill-ring.  One problem here is that everything is still
> text
> >> and
> >> >> >> >>>>   pastable only *before* the mime export process, which means
> >> that
> >> >> >> >>>>   linked images wouldn't resolve after pasting into the email
> >> >> client.
> >> >> >> >>>>
> >> >> >> >>>> 2) having the function generate a new mail buffer containing
> the
> >> >> >> >>>>   exported content.  This buffer would need to have it's
> >> >> >> >>>>   `buffer-file-name' set, for images to resolve during
> export.
> >>  I'm
> >> >> >> >>>> not
> >> >> >> >>>>   sure how this should best work.
> >> >> >> >>>>
> >> >> >> >>>> Thanks -- Eric
> >> >> >> >>>>
> >> >> >> >>>> Footnotes:
> >> >> >> >>>> [1]  http://github.com/eschulte/org-mime
> >> >> >> >>>
> >> >> >> >>>
> >> >> >> >>> _______________________________________________
> >> >> >> >>> Emacs-orgmode mailing list
> >> >> >> >>> Please use `Reply All' to send replies to the list.
> >> >> >> >>> Emacs-orgmode@gnu.org
> >> >> >> >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >> >> >> >>
> >> >> >> >> - Carsten
> >> >> >>
> >> >> >> _______________________________________________
> >> >> >> Emacs-orgmode mailing list
> >> >> >> Please use `Reply All' to send replies to the list.
> >> >> >> Emacs-orgmode@gnu.org
> >> >> >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >> >> >>
> >> >> >>
> >> >>
> >>
>
>

[-- Attachment #1.2: Type: text/html, Size: 31785 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14 18:00                                                       ` Andrew Hyatt
@ 2010-04-14 19:26                                                         ` Bernt Hansen
  0 siblings, 0 replies; 63+ messages in thread
From: Bernt Hansen @ 2010-04-14 19:26 UTC (permalink / raw)
  To: Andrew Hyatt; +Cc: emacs-orgmode

Andrew Hyatt <ahyatt@gmail.com> writes:

> Thanks! I  finally got it to work. I actually did have the latest
> code, but my issue was that when I upgraded to the new org, I forgot
> to byte-compile before I did M-x org-reload.
>
> After I got your latest code, it all works now.  I'm looking forward
> to using it!
>

This is one reason I have stopped byte-compiling mine.  I haven't
noticed a speed degradation and it's one less step each time I upgrade
org-mode.  Just check out the version of org I want to play with and 

   M-x org-reload

and I'm done.

Other reasons (I can think of immediately):

  - No more issues with compiled version being different than the
    sources -- since there is no compiled version
  - Stack dumps are more readable
  - Hacking on the code is easier
  - Tracking down source commits for bugs with git bisect doesn't need
    extra compilation steps (or time)

Regards,
Bernt

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14 15:12                                                     ` Eric Schulte
@ 2010-04-14 19:38                                                       ` Eric S Fraga
  2010-04-15  2:49                                                         ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Eric S Fraga @ 2010-04-14 19:38 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1598 bytes --]

On Wed, 14 Apr 2010 09:12:59 -0600, "Eric Schulte" <schulte.eric@gmail.com> wrote:
> 
> Hi Eric,
> 
> Thanks for the explicit feedback, it's very helpful.

You're very welcome!  It's the least I can do.

> > 6. try org-mime-org-buffer-htmlize again and now there is no error but
> > the output is:
> >
> 
> I see the problem here, I've just pushed up a change to org-mime.el
> which will ensure that your html mime alternative will no longer be
> nil.

Thanks.   I've pulled and it now works better, in that the HTML
element is now not-nil.  However, it's not quite right and other
aspects are still not working.  I'm attaching three files: the original
org file I'm using to test the mime encoding, a small image used for
the test, and the resulting message I receive when I've sent the
result of mime exporting.

There are definitely problems in encoding images, whether one
explicitly linked to in the org file or one created for latex
equations.  Some (maybe all?) of the problems may be due to
Wanderlust.  I imagine you don't use WL so if there's any help I can
provide in debugging this combination, please let me know!

I do note that the text contents for the email created in the buffer
do differ from what I get when I explicitly insert attachments.

> However, you will continue to have "t" as your text alternative until
> you ensure that you are loading the latest version of the core of
> org-mode, as described in my recent email to Andrew.

I am most definitely *always* using the latest version!  Currently, I
have "Org-mode version 6.35g (release_6.35g.48.g3102)".

Thanks,
eric

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]


* Testing mime in org

This file will provide a simple test for the new mime encoding and
exporting features in org-mode.

The most interesting aspect may be the use of \(\displaystyle y = \sum_i^n x_i^2\)
and, please, see the figure:

[[./mip.png]]

[-- Attachment #3: mip.png --]
[-- Type: image/png, Size: 29381 bytes --]

[-- Attachment #4: 6128.eml --]
[-- Type: application/octet-stream, Size: 3040 bytes --]

Return-path: <ucecesf@ucl.ac.uk>
Envelope-to: e.fraga@ucl.ac.uk
Delivery-date: Wed, 14 Apr 2010 20:24:51 +0100
Received: from imap-server.ucl.ac.uk [144.82.111.3]
	by lobo with IMAP (fetchmail-6.3.13)
	for <ucecesf@localhost> (single-drop); Wed, 14 Apr 2010 20:27:41 +0100 (BST)
Received: from 79-73-73-7.dynamic.dsl.as9105.com ([79.73.73.7] helo=lobo.ucl.ac.uk)
	by vscane-c.ucl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128)
	(Exim 4.60)
	(envelope-from <ucecesf@ucl.ac.uk>)
	id 1O28Cc-0006PE-TV; Wed, 14 Apr 2010 20:24:47 +0100
Date: Wed, 14 Apr 2010 20:24:35 +0100
Message-ID: <87iq7tq1l8.wl%ucecesf@ucl.ac.uk>
From: Eric S Fraga <ucecesf@ucl.ac.uk>
To: Eric S Fraga <ericsfraga@googlemail.com>
CC: Eric S Fraga <e.fraga@ucl.ac.uk>
Subject: testing mime
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka)
 FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.1 (i486-pc-linux-gnu)
 MULE/6.0 (HANACHIRUSATO)
Reply-To: e.fraga@ucl.ac.uk
MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_Apr_14_20:24:35_2010-2"
X-UCL-MailScanner-Information: Please contact the UCL Helpdesk, helpdesk@ucl.ac.uk for more information
X-UCL-MailScanner: Found to be clean
X-UCL-MailScanner-From: ucecesf@ucl.ac.uk
X-Spam-Status: No

--Multipart_Wed_Apr_14_20:24:35_2010-2
Content-Type: multipart/alternative;
 boundary="Multipart_Wed_Apr_14_20:24:35_2010-1"
Content-Transfer-Encoding: 7bit

--Multipart_Wed_Apr_14_20:24:35_2010-1
Content-Type: text/plain;
* Testing mime in org

This file will provide a simple test for the new mime encoding and
exporting features in org-mode.

The most interesting aspect may be the use of \(\displaystyle y = \sum_i^n x_i^2\)
and, please, see the figure:

[[./mip.png; charset=US-ASCII


--]]

--Multipart_Wed_Apr_14_20:24:35_2010-1
Content-Type: text/html;<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">Testing mime in org </h2>
<div class="outline-text-2" id="text-1">


<p>
This file will provide a simple test for the new mime encoding and
exporting features in org-mode.
</p>
<p>
The most interesting aspect may be the use of <img src="cid:_home_ucecesf_s_test_ltxpng_mimetest_05c1a02eec5cf8f123c1dd3164de1c5811ca6d5e.png" alt="\(\displaystyle y = \sum_i^n x_i^2\)"/>
and, please, see the figure:
</p>
<p>
<img src="cid:_home_ucecesf_s_test_mip.png"  alt="./mip.png" />
</p></div>
</div>

--; charset=US-ASCII


--Multipart_Wed_Apr_14_20:24:35_2010-1--

--Multipart_Wed_Apr_14_20:24:35_2010-2
Content-Type: application/octet-stream; type=image/png
Content-ID: _home_ucecesf_s_test_mip.png; filename="/home/ucecesf/s/test/mip.png"
Content-Transfer-Encoding: base64


--Multipart_Wed_Apr_14_20:24:35_2010-2
Content-Type: application/octet-stream; type=image/png
Content-ID: _home_ucecesf_s_test_ltxpng_mimetest_05c1a02eec5cf8f123c1dd3164de1c5811ca6d5e.png; filename="/home/ucecesf/s/test/ltxpng/mimetest_05c1a02eec5cf8f123c1dd3164de1c5811ca6d5e.png"
Content-Transfer-Encoding: base64

--Multipart_Wed_Apr_14_20:24:35_2010-2--

[-- Attachment #5: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please 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] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-14 19:38                                                       ` Eric S Fraga
@ 2010-04-15  2:49                                                         ` Eric Schulte
  2010-04-15 15:47                                                           ` Eric Schulte
  0 siblings, 1 reply; 63+ messages in thread
From: Eric Schulte @ 2010-04-15  2:49 UTC (permalink / raw)
  To: e.fraga; +Cc: emacs-orgmode

Eric S Fraga <ucecesf@ucl.ac.uk> writes:

[...]

> Thanks.   I've pulled and it now works better, in that the HTML
> element is now not-nil.  However, it's not quite right and other
> aspects are still not working.  I'm attaching three files: the original
> org file I'm using to test the mime encoding, a small image used for
> the test, and the resulting message I receive when I've sent the
> result of mime exporting.
>
> There are definitely problems in encoding images, whether one
> explicitly linked to in the org file or one created for latex
> equations.  Some (maybe all?) of the problems may be due to
> Wanderlust.  I imagine you don't use WL so if there's any help I can
> provide in debugging this combination, please let me know!
>

Yes, there absolutely is something you can do to help.

I think you're right that my poor WL syntax is most likely the problem.
All of the WL specific syntax is in the `org-mime-file' and
`org-mime-multipart' functions.  To start could you try replace the
'semi portion of the case statement in `org-mime-multipart' with the
following (I'd paste the whole function but it'd break my outgoing gnus
email) the syntax here is updated based on a function from
http://www.emacswiki.org/emacs/WlFaq#toc10.

--8<---------------cut here---------------start------------->8---
('semi (concat
            "--" "<<alternative>>-{\n"
            "--" "[[text/plain]]\n" plain
            "--" "[[text/html]]\n"  html
            "--" "}-<<alternative>>\n"))
--8<---------------cut here---------------end--------------->8---

That *should* fix the exportation of html portions w/o pictures, the WL
syntax in `org-mime-file' will need to be fixed for image attachments.

>
> I do note that the text contents for the email created in the buffer
> do differ from what I get when I explicitly insert attachments.
>

yes, hopefully once these are brought into line then org-mime will work
for WL as well as gnus.

Thanks -- Eric

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [ANN] org-mime -- using orgmode to send html mail?
  2010-04-15  2:49                                                         ` Eric Schulte
@ 2010-04-15 15:47                                                           ` Eric Schulte
  0 siblings, 0 replies; 63+ messages in thread
From: Eric Schulte @ 2010-04-15 15:47 UTC (permalink / raw)
  To: e.fraga; +Cc: emacs-orgmode

Org-mime should now fully support the WL mailer, thanks to Eric S Fraga.

I've updated the documentation on worg, but basically to use org-mime
with WL, you need only add the following to your config.

--8<---------------cut here---------------start------------->8---
(require 'org-mime)
(setq org-mime-library 'semi)
--8<---------------cut here---------------end--------------->8---

Now if any VM users want to add VM mime syntax to the `org-mime-file'
and `org-mime-multipart' functions we should have full coverage of the
big 3 Emacs mailers.

Thanks -- Eric

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Eric S Fraga <ucecesf@ucl.ac.uk> writes:
>
> [...]
>
>> Thanks.   I've pulled and it now works better, in that the HTML
>> element is now not-nil.  However, it's not quite right and other
>> aspects are still not working.  I'm attaching three files: the original
>> org file I'm using to test the mime encoding, a small image used for
>> the test, and the resulting message I receive when I've sent the
>> result of mime exporting.
>>
>> There are definitely problems in encoding images, whether one
>> explicitly linked to in the org file or one created for latex
>> equations.  Some (maybe all?) of the problems may be due to
>> Wanderlust.  I imagine you don't use WL so if there's any help I can
>> provide in debugging this combination, please let me know!
>>
>
> Yes, there absolutely is something you can do to help.
>
> I think you're right that my poor WL syntax is most likely the problem.
> All of the WL specific syntax is in the `org-mime-file' and
> `org-mime-multipart' functions.  To start could you try replace the
> 'semi portion of the case statement in `org-mime-multipart' with the
> following (I'd paste the whole function but it'd break my outgoing gnus
> email) the syntax here is updated based on a function from
> http://www.emacswiki.org/emacs/WlFaq#toc10.
>
> ('semi (concat
>             "--" "<<alternative>>-{\n"
>             "--" "[[text/plain]]\n" plain
>             "--" "[[text/html]]\n"  html
>             "--" "}-<<alternative>>\n"))
>
> That *should* fix the exportation of html portions w/o pictures, the WL
> syntax in `org-mime-file' will need to be fixed for image attachments.
>
>>
>> I do note that the text contents for the email created in the buffer
>> do differ from what I get when I explicitly insert attachments.
>>
>
> yes, hopefully once these are brought into line then org-mime will work
> for WL as well as gnus.
>
> Thanks -- Eric

^ permalink raw reply	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2010-04-15 15:48 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-22  2:34 using orgmode to send html mail? Matt Price
2010-03-22 15:44 ` Matt Price
2010-03-22 20:18 ` David Maus
2010-03-23 19:54   ` Eric Schulte
2010-03-23 21:46     ` Xiao-Yong Jin
2010-03-24 15:00       ` Eric Schulte
2010-03-24 17:50         ` Dan Davison
2010-03-24 18:01           ` Eric Schulte
2010-03-24 19:12             ` David Maus
2010-03-24 20:19               ` Eric Schulte
2010-03-25 21:17                 ` David Maus
2010-03-26 14:53                   ` Eric Schulte
2010-03-26 16:04                     ` David Maus
2010-03-26 16:32                       ` Eric Schulte
2010-03-31 18:12                         ` [CONTRIB?] " Eric Schulte
2010-03-31 20:05                           ` Dan Davison
2010-03-31 21:10                             ` Eric Schulte
2010-03-31 21:37                               ` Dan Davison
2010-04-01 14:22                                 ` Eric Schulte
2010-04-05  5:39                                   ` Eric Schulte
2010-04-05  6:49                                     ` Carsten Dominik
2010-04-05 15:31                                       ` Eric Schulte
2010-04-09 16:41                                         ` [ANN] org-mime -- " Eric Schulte
2010-04-09 17:41                                           ` Matt Price
2010-04-09 19:11                                             ` Eric Schulte
2010-04-09 19:22                                             ` David Maus
2010-04-09 20:34                                               ` Eric Schulte
2010-04-12 13:37                                           ` Andrew Hyatt
2010-04-12 17:22                                             ` Eric Schulte
2010-04-13  1:31                                               ` Andrew Hyatt
2010-04-14  0:57                                                 ` Eric Schulte
2010-04-14  1:57                                                   ` Andrew Hyatt
2010-04-14 14:59                                                     ` Eric Schulte
2010-04-14 18:00                                                       ` Andrew Hyatt
2010-04-14 19:26                                                         ` Bernt Hansen
2010-04-14  8:39                                                   ` Eric S Fraga
2010-04-14 15:12                                                     ` Eric Schulte
2010-04-14 19:38                                                       ` Eric S Fraga
2010-04-15  2:49                                                         ` Eric Schulte
2010-04-15 15:47                                                           ` Eric Schulte
2010-04-13 23:03                                           ` Eric S Fraga
2010-04-14  1:22                                             ` Eric Schulte
2010-04-05 13:54                                     ` [CONTRIB?] " Dan Davison
2010-04-05 14:50                                       ` David Maus
2010-04-05 14:53                                       ` Dan Davison
2010-04-05 15:30                                         ` Eric Schulte
2010-04-01 17:37                           ` Sivaram Neelakantan
2010-04-01 17:45                           ` Sivaram Neelakantan
2010-03-31 20:37                         ` David Maus
2010-03-31 22:03                           ` Eric Schulte
2010-04-02  7:04                             ` David Maus
2010-04-02 23:01                               ` Eric Schulte
2010-04-03  9:19                                 ` David Maus
2010-04-04 17:52                                   ` Eric Schulte
2010-04-01  7:53                           ` Vagn Johansen
2010-04-02  6:34                             ` David Maus
2010-04-02 14:57                               ` Dan Davison
2010-04-02 17:25                                 ` David Maus
2010-04-02 21:10                                   ` Eric Schulte
2010-04-03  9:00                                     ` David Maus
2010-04-03 12:03                                       ` David Maus
2010-04-04  2:41                                         ` Eric Schulte
2010-04-04 10:00                                           ` David Maus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).