Apple mail message ID to drafts - help

Hi,

Was hopping someone can help.
trying to write an AppleScript that takes the message ID and subject of the currently selected message in apple mail and send them to a new draft with title being subject of the email and content is the message ID.

however, despite various attempts I am not able to get the subject to be the title of the draft, any help?

tell application "Mail"
	set selectedMessages to selection
	if selectedMessages is not {} then
		set theMessage to first item of selectedMessages
		set theMessageSubject to subject of theMessage
		set theMessageURL to "message://%3c" & message id of theMessage & "%3e"
	end if
end tell

if theMessageURL is not "" then
	tell application "Drafts"
		activate
		set theDraft to make new draft
		tell theDraft
			set content to theMessageURL
			set name to theMessageSubject
		end tell
	end tell
end if```

A draft does not have a “name” - there’s no title or subject, you have to concatenate the values. The syntax you are looking for would be:

tell application "Mail"
	set selectedMessages to selection
	if selectedMessages is not {} then
		set theMessage to first item of selectedMessages
		set theMessageSubject to subject of theMessage
		set theMessageURL to "message://%3c" & message id of theMessage & "%3e"
	end if
end tell

if theMessageURL is not "" then
	tell application "Drafts"
		activate
		make new draft with properties {content:theMessageSubject & "

" & theMessageURL, flagged:false, tags:{}}
	end tell
end if
1 Like

thank you! works perfectly.