Applescript to Copy Mail Subject?

I’m an AppleScript novice with zero experience, but I have a case where I’d like to copy the subject of an email (in Mail.app) and hope to find the right AppleScript text.

Has anyone got any ideas?

referencing this: https://talk.automators.fm/t/universal-apple-mail-message-url/4702/13?u=flohgro

tell application "Mail"
	set _msgs to selected messages of message viewer 0
	if (_msgs is not equal to missing value) then
		set _msg to first item of _msgs
			set the clipboard to (subject of _msg) as string
		
	end if
end tell

I did not test this but I think its a good startingpoint

@FlohGro there is an end tell that doesn’t belong in line six. The script (that works) should be

tell application "Mail"
	set _msgs to selected messages of message viewer 0
	if (_msgs is not equal to missing value) then
		set _msg to first item of _msgs
		set the clipboard to (subject of _msg) as string
	end if
end tell

From experience I know, it’s always a good idea to test scripts before posting them :sunglasses:

Thats why I said in the end that i didnt Test it.
I posted it when my mac wasnt available. I‘ll edit it about, thanks

Wow! Great! Thanks for that

1 Like