Copy mail message contents into clipboard

Applescript beginner here.

I am trying to find a script that would locate an e-mail with a specific subject, then take only the contents of the e-mail (the message body, not the to/from info) and copy it to the clipboard. I tried the “get content” command but it didn’t seem to work.

In automator, I was able to do something close to this, but it copied the entire message contents into the clipboard. I was not able to filter out just the content of the message.

Thanks for any help!

in appliecations:applescript:example scripts/mail/ you will find some examples of how to manipulate meassages

that should get you started.

also if you show us what you got we may be able to tell you what it is your doig wrong


Hi whatne1wuddo,

Thanks for your comment on my website. Nevertheless I prefer to answer your question right here on MacScripter.

I just modified Apple’s sample script a bit to create an AppleScript that matches your requirement. The code below will copy the content (body) of the first matching eMail to the clipboard:

using terms from application "Mail"
	on perform mail action with messages matchmsgs for rule mailrule
		tell application "Mail"
			set msg to item 1 of matchmsgs
			set msgcontent to (content of msg) as Unicode text
		end tell
		set the clipboard to msgcontent
	end perform mail action with messages
end using terms from

Maybe that is already good enough?

Best regards from Germany!