Dragging emails from apple mail to browser

I would like to create a web app where you can drag and drop emails from Apple Mail (on macOS). When you drag emails to the desktop an .eml file is created, but when you drag emails to the browser no file is being transferred, I can only get the mail’s subject. So is it possible to drag and drop emails from Apple Mail to browsers? And if yes, then how? So far I've tried chrome and safari, but neither got any files with the dragged element. On windows with outlook or thunderbird this wasn’t an issue, so I hope it can be done with apple mail as well. Thanks in advance

Replies

Have you searched for existing Mail Plug-Ins?

The .eml format contains all the header info in addition to the standard GUI, like To/From, Date/Time, CC, BCC, message size, attachment details and then of course, the body of the message itself. A browser doesn't know what to do with the header info unless you add some structure or remove it all together. Mail > View > Message > Raw Source (⌥⌘U / Option+Command+U) will open plain text window.

You say you'd like to make a web app for doing this? But also the ability to drag local .eml file to browser window?

The web app scenario would require sending the .eml to a server where a script parses all the header info out or converts to .json or .xml. Then whatever language you use would structure the appropriate html, css, js in order to render it to the UI.

On the other hand, a local .eml file could be parsed out using AppleScript, Script Editor, Automator or.... any other dev tool you like. e.g. Python Selenium, Node.

My suggestion? Check for existing browser extensions or Mail Plug-ins. I'm sure someone has done something similar. Or setup rules in Mail that would run automation process to a smart or watch folder, then using the dev tools I mentioned above, exports the .eml to .html Love to hear how it goes!

Any update here? When I drag an email from apple mail and drop it in any web browser, event.dataTransfer.files is empty. All I can get is an URL list (event.dataTransfer.getData("text/uri-list") = "message:<Message-ID>"), no .eml file