Add content to reply message in Apple Mail

Hi all,

can somebody please tell me how to add content to a reply message in Apple Mail.

I can generate a reply but I don’t seem to be able to add content to the message.

set messageID to 37

tell application "Mail"
	set theMessages to every message of mailbox "INBOX" of account "PICK AND PACK" whose id is messageID
	if theMessages is not {} then set theMessage to item 1 of theMessages
	set theOutgoingMessage to reply theMessage with opening window and reply to all
	tell theOutgoingMessage
		make new to recipient at end of to recipients with properties {name:"FTP_Server", address:"email_address"}
		--Add content to the reply message
	end tell
	set f to content of theOutgoingMessage
end tell

Thanks,
Nik

Hey Nik,

You can’t add anything to a message (with AppleScript) after it’s created, so a reply or forward is effectively dead as soon as it is created.

Your only option is to create a brand new message with the content you want, and there are limits to what vanilla AppleScript will do.

AppleScriptObjC can create a styled-text email, but working with the source of your original can be a headache (depending upon how it’s formatted).

Some things can be done with GUI-Scripting via System Events.


Chris


{ MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.11.6 }
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Many thanks for your reply Chris.

I was hoping that I’d just missed a trick but looks like a bit of a deadened. Interestingly the same problem seems to apply to Outlook. Whilst I was waiting for a response to my post I rewrote the script for Outlook. Although you can “reply” to a message in Outlook and add content to the message it still doesn’t contain the original message:

tell application "Microsoft Outlook"
	set theMessage to the selection
	set replyMessage to reply to theMessage without opening window
	set the content of replyMessage to "New message content"
end tell

An if you choose to show the reply message window

	set replyMessage to reply to theMessage with opening window

The new content isn’t inserted!

I’ve seen workarounds for this, setting a variable of the original message content and then reinserting it after the new content but it’s not styled the same.

Thanks,
Nik