Get body-html

122 views
Skip to first unread message

Daniel Fleischer

unread,
May 28, 2022, 7:05:17 AM5/28/22
to mu-di...@googlegroups.com
Hi!

I'm using org-msg which uses orgmode to create and reply to HTML emails.
Due to recent changes in mu, :body-html is not part of the message. How
can I get it, say starting with a non-nil `mu4e-compose-parent-message`?

Thanks,

--

Daniel Fleischer

Dirk-Jan C. Binnema

unread,
May 28, 2022, 8:15:32 AM5/28/22
to mu-di...@googlegroups.com

On Saturday May 28 2022, Daniel Fleischer wrote:

> I'm using org-msg which uses orgmode to create and reply to HTML
> emails. Due to recent changes in mu, :body-html is not part of the
> message. How can I get it, say starting with a non-nil
> `mu4e-compose-parent-message`?

You cannot do so directly. For the specific case of org-msg, I think the
way forward is to use its gnus support instead; it'll probably need a
little tweaking to use with mu4e (and perhaps some tweaks on the mu4e side).

Kind regards,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
gpg: 6987 9CED 1745 9375 0F14 DA98 11DD FEA9 DCC4 A036

Daniel Fleischer

unread,
May 28, 2022, 8:48:38 AM5/28/22
to mu-di...@googlegroups.com
Dirk-Jan C. Binnema [2022-05-28 Sat 14:39] wrote:

> You cannot do so directly. For the specific case of org-msg, I think the
> way forward is to use its gnus support instead; it'll probably need a
> little tweaking to use with mu4e (and perhaps some tweaks on the mu4e side).

Thanks for the response and suggesting some direction forward.

Best,

--

Daniel Fleischer

Christophe Troestler

unread,
May 28, 2022, 9:36:33 AM5/28/22
to mu-di...@googlegroups.com

Hi,

On 28 May 2022 at 14:39 +03, "Dirk-Jan C. Binnema" <dj...@djcbsoftware.nl> wrote:

On Saturday May 28 2022, Daniel Fleischer wrote:

I'm using org-msg which uses orgmode to create and reply to HTML emails. Due to recent changes in mu, :body-html is not part of the message. How can I get it, say starting with a non-nil `mu4e-compose-parent-message`?

You cannot do so directly. For the specific case of org-msg, I think the way forward is to use its gnus support instead; it'll probably need a little tweaking to use with mu4e (and perhaps some tweaks on the mu4e side).

I've modified org-msg as follows:

@@ -1160,7 +1160,12 @@ a html mime part, it returns t, nil otherwise."

 (defun org-msg-article-htmlp-mu4e ()
   "Return t if the current mu4e article is HTML article."
-  (when (mu4e-message-field mu4e-compose-parent-message :body-html) t))
+  (let ((msg mu4e-compose-parent-message))
+    (or (mu4e-message-field msg :body-html)
+       (with-temp-buffer
+         (insert-file-contents-literally
+          (mu4e-message-readable-path msg) nil nil nil t)
+         (org-msg-article-htmlp)))))

(It is not ready for a PR.)

Hope it helps,
C.

Daniel Fleischer

unread,
May 28, 2022, 2:39:24 PM5/28/22
to mu-di...@googlegroups.com
Christophe Troestler [2022-05-28 Sat 15:36] wrote:

> I've modified org-msg as follows:
>
> @@ -1160,7 +1160,12 @@ a html mime part, it returns t, nil otherwise."
>
> (defun org-msg-article-htmlp-mu4e ()
> "Return t if the current mu4e article is HTML article."
> - (when (mu4e-message-field mu4e-compose-parent-message :body-html) t))
> + (let ((msg mu4e-compose-parent-message))
> + (or (mu4e-message-field msg :body-html)
> + (with-temp-buffer
> + (insert-file-contents-literally
> + (mu4e-message-readable-path msg) nil nil nil t)
> + (org-msg-article-htmlp)))))
>
> Hope it helps,

Thanks for the patch! I did it, and also made the following change:

(defun org-msg-save-article-for-reply-mu4e ()
"Export the currently visited mu4e article as HTML."
(let* ((msg mu4e-compose-parent-message)
- (html (mu4e-message-field msg :body-html))
+ (html (with-temp-buffer
+ (insert-file-contents (mu4e-message-readable-path msg))
+ (buffer-substring-no-properties (point-min) (point-max))))
(file (make-temp-file "org-msg" nil ".html")))

The draft mail looks good but when when doing `org-msg-preview` the
resulting HTML is full of junk in the bottom.

--

Daniel Fleischer

Daniel Fleischer

unread,
Jun 13, 2022, 2:53:14 AM6/13/22
to mu-di...@googlegroups.com
Daniel Fleischer [2022-05-28 Sat 21:39] wrote:

> Thanks for the patch! I did it, and also made the following change:
>
> (defun org-msg-save-article-for-reply-mu4e ()
> "Export the currently visited mu4e article as HTML."
> (let* ((msg mu4e-compose-parent-message)
> - (html (mu4e-message-field msg :body-html))
> + (html (with-temp-buffer
> + (insert-file-contents (mu4e-message-readable-path msg))
> + (buffer-substring-no-properties (point-min) (point-max))))
> (file (make-temp-file "org-msg" nil ".html")))
>
> The draft mail looks good but when when doing `org-msg-preview` the
> resulting HTML is full of junk in the bottom.

I had to clean the HTML in the file-on-disk; so the added lines are
actually:

(html (with-temp-buffer
(insert-file-contents (mu4e-message-readable-path msg))
(quoted-printable-decode-region (point-min) (point-max))
(beginning-of-buffer)
(search-forward "DOCTYPE html")
(beginning-of-line)
(buffer-substring-no-properties (point) (point-max))))

Now it works.

--

Daniel Fleischer

Daniel Fleischer

unread,
Jul 1, 2022, 10:06:01 AM7/1/22
to mu-di...@googlegroups.com
"Dirk-Jan C. Binnema" <dj...@djcbsoftware.nl>
writes:

> You cannot do so directly. For the specific case of org-msg, I think the
> way forward is to use its gnus support instead; it'll probably need a
> little tweaking to use with mu4e (and perhaps some tweaks on the mu4e side).

It has been a few weeks and there's the official 1.8 release so I wanted
to try and get back to this issue. I couldn't get a good general
solution. I think being able to compose and reply to HTML messages is
important to many people who enjoy the mu/mu4e project. Are there any
solutions people are developing? Maybe some ideas from Dirk-Jan on how
to get HTML from a message in file or from the mu server.

Thanks,

Daniel Fleischer

Dirk-Jan C. Binnema

unread,
Jul 2, 2022, 4:32:30 AM7/2/22
to mu-di...@googlegroups.com
I think some people have good results with org-msg for composing
messages. For receiving html messages and responding in html, that's
fairly hard to do.

Some hybrid may be possible... take a look at gnus, if they have the
needed functionality, we may be able to use that.

Tim Cross

unread,
Jul 2, 2022, 5:03:47 AM7/2/22
to mu-di...@googlegroups.com

"Dirk-Jan C. Binnema" <dj...@djcbsoftware.nl> writes:

> On Friday Jul 01 2022, Daniel Fleischer wrote:
>
>> "Dirk-Jan C. Binnema" <dj...@djcbsoftware.nl>
>> writes:
>>
>>> You cannot do so directly. For the specific case of org-msg, I think the
>>> way forward is to use its gnus support instead; it'll probably need a
>>> little tweaking to use with mu4e (and perhaps some tweaks on the mu4e side).
>>
>> It has been a few weeks and there's the official 1.8 release so I wanted
>> to try and get back to this issue. I couldn't get a good general
>> solution. I think being able to compose and reply to HTML messages is
>> important to many people who enjoy the mu/mu4e project. Are there any
>> solutions people are developing? Maybe some ideas from Dirk-Jan on how
>> to get HTML from a message in file or from the mu server.
>
> I think some people have good results with org-msg for composing
> messages. For receiving html messages and responding in html, that's
> fairly hard to do.
>
> Some hybrid may be possible... take a look at gnus, if they have the
> needed functionality, we may be able to use that.
>

I was originally using org-msg, but now I find org-mime easier to work
with.

Correctly formatted email messages will have both a plain text and an
HTML version. However, many mail clients produce really really bad HTML
(outlook is terrible), so working directly with the HTML included when
replying is extremely difficult and most programs will just use the
plain text version and wrap the HTML part of the reply in 'new' html.

One reason I like org-mime is that I can write my message using org
syntax (including source blocks, tables etc) and have it produce nice
looking HTMLi which I can easily style to make it look how I like.

org-msg also worked well, but there were a few things I found a little
more difficult to tweak to get the result I wanted.

Daniel Fleischer

unread,
Jul 2, 2022, 10:35:38 AM7/2/22
to mu-di...@googlegroups.com
Dirk-Jan C. Binnema [2022-07-02 Sat 11:24] wrote:

> I think some people have good results with org-msg for composing
> messages. For receiving html messages and responding in html, that's
> fairly hard to do.

Yes, I mentioned org-msg in the original post; it's doing the heavy
lifting of converting org to HTML, attaching files and replying with
HTML to HTML.

> Some hybrid may be possible... take a look at gnus, if they have the
> needed functionality, we may be able to use that.

Org-msg has support for mu4e, Gnus and notmuch and using org-msg + Gnus
works correctly (for this scenario), but I like mu4e and want to use it
for all my email needs.

So Gnus knows how to extract HTML from maildir files but the backends
are very different; Gnus creates `.nnmaildir` folders with symbolic
links to the messages and some hashmaps with all the info while mu uses
a DB to match message-id with the message files.

It's something I can look into and it might end up being some patch for
org-msg in the end, or not. I just wanted to hear some ideas and
thoughts.

--
Daniel Fleischer

Dirk-Jan C. Binnema

unread,
Jul 2, 2022, 12:21:11 PM7/2/22
to mu-di...@googlegroups.com

On Saturday Jul 02 2022, Daniel Fleischer wrote:

> Dirk-Jan C. Binnema [2022-07-02 Sat 11:24] wrote:
>
>> I think some people have good results with org-msg for composing
>> messages. For receiving html messages and responding in html, that's
>> fairly hard to do.
>
> Yes, I mentioned org-msg in the original post; it's doing the heavy
> lifting of converting org to HTML, attaching files and replying with
> HTML to HTML.

Yes, but the hard part is to support round-tripping/editing the html. I
don't think org-msg does that. Can still be useful of course.

>> Some hybrid may be possible... take a look at gnus, if they have the
>> needed functionality, we may be able to use that.
>
> Org-msg has support for mu4e, Gnus and notmuch and using org-msg + Gnus
> works correctly (for this scenario), but I like mu4e and want to use it
> for all my email needs.
>
> So Gnus knows how to extract HTML from maildir files but the backends
> are very different; Gnus creates `.nnmaildir` folders with symbolic
> links to the messages and some hashmaps with all the info while mu uses
> a DB to match message-id with the message files.
>
> It's something I can look into and it might end up being some patch for
> org-msg in the end, or not. I just wanted to hear some ideas and
> thoughts.

You don't need very much from gnus; and specifically when I looked at
org-msg, I'd suspect its gnus backend to mostly work for mu4e as well,
though some tweaking is probably needed.

If there's anything needed on the mu4e side, let us know.

Kind regards,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
gpg: 6987 9CED 1745 9375 0F14 DA98 11DD FEA9 DCC4 A036
3

Thomas Bergheim

unread,
Oct 28, 2022, 10:45:12 AM10/28/22
to mu-discuss
Hey guys,

I recently upgraded to mu 1.8 myself, breaking org-msg replies. They worked flawlessly using 1.6, and while I realize this might not be the responsibility of mu here, I wanted to hear if anyone here ended up with a working solution for this (aside from moving to org-mime).

Reply all
Reply to author
Forward
0 new messages