Exporting an Email from Apple Mail into Roam Research

Any ideas of how I can convert the contents of an email into text and import it into my Roam Research? At present I just copy and paste. Can that be automated?

Hey @yashodhankhare,

You can't extract rich text from messages via AppleScript, but you can get the body and other elements of an email as plain text.

Appended is a macro that will just get the body – but more can be done.

I don't have Roam, but a quick Google looks like some automation should be possible.


Mail ⇢ Extract Selected Email Text v1.00.kmmacros (5.7 KB)

This was helpful, but where does it paste the contents. I set this up in KM. Then what? Should I run it within Apple mail or in Roam? Sorry, his is a very dumb question, but I am not a programmer. Thanks for the help and if you could just tell me the next steps, I would be grateful.

You don't at this point. The text pops up in a window, and from there you can copy it if you want.

However – you can change the output setting at the top of the Execute an AppleScript action from 'display results in a window' to a number of different options.


I'd set it up in an Apple Mail specific macro group, because you're going to export while you're reading mail.

I don't know the next few steps, because I don't have Roam.

You need to look at the steps you'd take to import by hand, and you need to look into the options (if any) for automation.

Ask on Roam's support forums if they have any, or get busy Googling...  :wink:


Many thanks, changing the output settings did the trick. I really appreciate your help. Actually, this KM forum is superior to most other forums is what I’ve realized. I had posted to Roam, but didn’t get any response. Anyway, thanks once again, this is useful for me and I don’t need any more ‘automation’.