The use case is: Robin wants to save an HTML email to a file to open it with their favourite web browser, either to be more secure or to profit from the credentials saved in the particular browser. With an email with a single main Content-type: text/html, there is no way (I could find) to save this content as HTML file. Right now there is no attachment shown in the header and even in the email structure view there is no context menu (and thus no "save as" entry in the contect menu). Also the "Save attachments" functionality on the email does not work as it says: There is no attachment. How to reproduce: * Get hold of an email with only one Content-Type: text/html as main contents. * Display it with Kmail (reproduced with kmail2 5.24.4 (23.08.4)) * Try right click on the message, "Save Attachments". -> Observed: does not work with a message: there is no attachment Expected: Should work and ask for a .html filename. * Enable email structure view * right click on the main part -> Observed: no context menu -> expected: context menu that offers working "open" and "save-as" menu entries beside the common ones
A sister case is https://bugs.kde.org/show_bug.cgi?id=126130 for exporting a full email including everything as html.
Currently, it is possible to save emails as mbox files by right-clicking on the message → "Save message". This opens a file dialog with the only possibility to filter for `.mbox` files. My proposal is to extend the filter to `.html` files and save the HTML part if the file extension is `.html`. This avoids the cluttering of the context menu and has similar behavior to Thunderbird, where I can select the wanted file type. This change would require refactoring in `messageviewer/utils/messageviewerutil`. `MessageViewer::Util::saveMessageInMboxAndGetUrl` would then check for the specified file extension of the user and extract and save the HTML part, if the extension is `.html`.
(In reply to Paul Schwabauer from comment #2) > Currently, it is possible to save emails as mbox files by right-clicking on > the message → "Save message". > This opens a file dialog with the only possibility to filter for `.mbox` > files. My proposal is to extend the filter to `.html` files and save the > HTML part if the file extension is `.html`. But won't this be a different semantic, saving a full email against saving just one body part?
- Regarding the message view: In `messagelib` there is already code that can save the HTML and open it with a browser: https://invent.kde.org/pim/messagelib/-/blob/c52d92a121d6678e96dcb8e00dbd9d61101dc67e/messageviewer/src/viewer/viewer_p.h#L488-L490 However, this code is hidden in a private class, and I can find no usage of it. My proposal would be to expose `ViewerPrivate::slotOpenInBrowser` in `Viewer` and add a new method `ViewerPrivate::exportToHtml` and `Viewer::exportToHtml` similar to the `exportToPdf` methods, that can be used by kmail. This change would require the extending of the context menu in kmail with "Export to HTML..." and "Open in browser". - Regarding the email/message structure view: Currently, it is not possible to save an HTML part in the message structure display, if the HTML is sent as a main body. To reproduce, open an HTML mail with the HTML as main body part and press CTRL-ALT-D to open the message structure display. Then right-click on the HTML part. If the HTML part is not at the top level, for example, with a multipart/alternative mail, it is possible to save, open and view the HTML part. However, this is not possible if the mail only consists of the HTML part. The reason is here: https://invent.kde.org/pim/messagelib/-/blob/c52d92a121d6678e96dcb8e00dbd9d61101dc67e/messageviewer/src/viewer/viewer_p.cpp#L1733-L1746. To fix this, the `isTopLevel()` check has to be removed. This change should have a minimal impact.
Here is the fix for the message structure viewer: https://invent.kde.org/pim/messagelib/-/merge_requests/188