My first post, and help's needed

I hope MPU can point me to a solution to what I thought would be a solved problem. For example, is there an Apple Script, KBM, or Shortcut to scrape text from an email from a defined address and share the text with another app? I’ve searched but have not found anything or anything that I could build on.


Can you ellaborate your use case a little more? Like, for example, which mail app are you using and the app you would like to send the text.

If you have an email opened in, you could create a Keyboard Maestro shortcut to send the keystrokes CMD-A + CMD-C to copy the text to the clipboard, activate the target app and then perform a CMD-V to paste it, but this may not work for what you are trying to achieve.

1 Like

Also: do you want this to happen automatically, or only when you invoke it from within Mail?

1 Like is my go-to, ultimately I would like to be able to send the text to an app on a defined list, but Apple notes in the first instance.

The script or similar would detect the unique email address and trigger the scrap and transfer.

I think the key here is to setup in a Mail Rule that when detects a message from that address runs an Apple Script

As an example, DEVONthink installs a script that captures the message so that you can add it as a filter. I would copy and paste the script for reference, but I think I would be violating copyright :frowning:


Thanks :slight_smile: At least there is a solution, good news!!

Maybe this AppleScript can serve as a reference:

It captures the message details, and then you would need to replace the


section to some snippet to create an item in Apple Notes.

1 Like

This solution seems complicated at best… to be honest, I would just forward the email to Evernote inbox and be done with it.

It does seem complicated for what, at least on the surface, should be a straightforward thing.

If you follow @pantulis’s suggestion about setting up a Mail Rule to run an AppleScript whenever a message comes in from a particular sender, the following AppleScript will create a new note with the message’s subject, date, and content. The note will be in a folder called “From Mail,” but that can be changed easily.

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		-- Loop through the messages captured by the rule
		repeat with theMessage in theMessages
			-- Get the pertinent message data
			set msgDate to date sent of theMessage
			set msgSubject to subject of theMessage
			set msgContent to content of theMessage
			-- Assemble the message data into a note
			set noteBody to "<div><h1>" & msgSubject & "</h1></div>" & linefeed & ¬
				"<div>" & msgDate & "</div>" & linefeed & ¬
				"<div><br/></div>" & linefeed & ¬
				"<div>" & msgContent & "</div>"
			-- Make a new note in the From Mail folder
			tell application "Notes"
				tell folder "From Mail"
					set msgNote to make new note with properties {body:noteBody}
				end tell
			end tell
		end repeat
	end perform mail action with messages
end using terms from

As for what’s complicated and what’s straightforward, that’s in the eye of the beholder. Mail Rule AppleScripts always have the same obscure and verbose boilerplate text at the beginning and end. I’ve never memorized it; I just copy it from a previous script.

That pretty sums up what I usually do with Apple Script in general :wink:

thank you for taking the time to pull the script together. I will give this a go and report back.

Unfortunately, there are some pitfalls to saving email messages via the content of the message.

Email messages are transmitted in a specific format, and can contact multiple “parts” (they are called multipart messages). For example, one email can contain a text and a separate HTML formatted version of the same message, and an email can also contain attachments. Just copying the full content of an email message can sometimes lead to unexpectedly complicated and less than useful results.

I generally think that the best approach is to move email messages to an app that understands them. You can easily script to save a message to a file, and I have my own script that can pull out the various parts including attachments into separate files, although I tend not to use this approach very much because again of the complexity of many email messages.

One thing to keep in mind: if an email is an HTML formatted messages that contains links (for example, to images), when you copy its content elsewhere, you will have the link to the image but not the image itself. Therefore, if you try to view the message at a later date, if the links no longer work, the images cannot be downloaded.

Actually capturing the formatted appearance of an email message means you should render the email to a formatted document, such as saving as a PDF. Problematically, this cannot be scripted in other than via UI scripting, which I have found to be glitchy.

I wish I could offer more reliably solutions, but I have been playing with this off and on for years and never hit on anything that I am completely satisfied with.

Thanks to everyone who responded to my first post on MPU. Clearly a supportive community. I used the script that @drdrang dropped into the thread, and after I realized I needed to create the folder in Notes, it worked a charm and gave me a platform from which to tinker. Many thanks :slight_smile:

My use case for the script wends all the way back to Tablet PC. I can’t type, and I find errors feeds my ADHD and wrecks my focus. Although I’ve bought and tried all the handwriting-to-text apps, the closest to the Tablet PC was Stylus, this is no longer supported and now does damage when it runs amok.

From here, it is the reMarkable for the pen-paper experience, OCR, email, and onward to Notes or the target app of choice.


I agree that much can be lost when saving the content of an email this way, but I figured @Mel had his reasons.

Missing from my script is a link back to the message itself. That would make it easy to see the message in its native environment.