Discussion:
Viewing HTML attachments with embedded pictures
(too old to reply)
cjsmall
2022-10-10 15:44:33 UTC
Permalink
I have a shell script filter called "attach_view" that handles a number of different attachment types, including HTML, PDF, Microsoft documents and various images. I bind "|attach_view\n" to an attachment key and can press it to see the selected attachment. This works fine for me.

However, I'm getting HTML emails that have embedded images. These come in as an HTML attachment, and a set of additional image attachments which are often in random order. Is there a method of being able to view the HTML with the attached images as you can with most GUI email readers? Has anyone tackled this very typical problem?

Thanks.
cjsmall
2022-10-10 17:51:47 UTC
Permalink
Post by cjsmall
I have a shell script filter called "attach_view" that handles a number
of different attachment types, including HTML, PDF, Microsoft
documents and various images. I bind "|attach_view\n" to an
attachment key and can press it to see the selected attachment.
his works fine for me.
However, I'm getting HTML emails that have embedded images.
These come in as an HTML attachment, and a set of additional
image attachments which are often in random order. Is there a
method of being able to view the HTML with the attached images
as you can with most GUI email readers? Has anyone tackled
this very typical problem?
Thanks.
Following up to my own post, here is an example. From the decoded
html file there is this line:

<img src="cid:183b8408554dbcb66d71" style="width:1364px;max-width:100%">

And from the original email message:

Content-Type:
image/jpeg; name="6674A791-428C-450F-9D38-F93951FD796D.jpeg"
Content-Disposition: inline;
filename="6674A791-428C-450F-9D38-F93951FD796D.jpeg"
Content-Transfer-Encoding: base64
Content-ID: <183b8408554dbcb66d71>
X-Attachment-Id: 183b8408554dbcb66d71
.... encoded image ...

Which, when saved, produces the file:

19F23E05-3F36-474E-AF64-54594565D171.jpeg

Short of writing a complex program that:

* creates a temporary directory
* filters the entire email, using munpack(1) to export all the image files
* extracts the HTML portion and then edits it to replace all <img> tags
with absolute paths to the actual image file

It's certainly doable, but I hope there is a tool that does this already! In
my searching I haven't found any suitable tool.
Christian Ebert
2022-10-24 22:09:57 UTC
Permalink
Post by cjsmall
* creates a temporary directory
* filters the entire email, using munpack(1) to export all the image files
* extracts the HTML portion and then edits it to replace all <img> tags
with absolute paths to the actual image file
It's certainly doable, but I hope there is a tool that does this already! In
my searching I haven't found any suitable tool.
shameless plug: viewhtmlmsg of
https://hg.phloxic.productions/muttils
does this.

Does not use munpack, I'm afraid, but python3.
--
LAST SHIP HOME --->> https://lastshiphome.de/en
Official Selection DOK.fest Munich 2018
German Ocean Film Award CineMare Kiel 2019
Best Documentary Feature Wales International Film Festival 2020
cjsmall
2022-10-24 23:15:14 UTC
Permalink
Post by Christian Ebert
* creates a temporary directory
* filters the entire email, using munpack(1) to export all the image files
* extracts the HTML portion and then edits it to replace all <img> tags
with absolute paths to the actual image file
It's certainly doable, but I hope there is a tool that does this already! In
my searching I haven't found any suitable tool.
shameless plug: viewhtmlmsg of
https://hg.phloxic.productions/muttils
does this.
Does not use munpack, I'm afraid, but python3.
Thanks Christian. I was just starting to write my own tool. I'll
download and try out yours! Much appreciated.
cjsmall
2022-10-27 20:48:54 UTC
Permalink
I just wanted to publically thank Christian Ebert for sharing his
python-based tool to view html attachments with embedded
images. It works great and saved me a lot of time and headaches
building my own.

Loading...