Cannot create Mail reply with custom sender address

I’m working on a pretty basic script to create a reply to the selected messages which sets the sender address to the address the email was originally sent to. (I have multiple email aliases which all resolve to the same account.)

global theAccount

tell application "Mail"
	set curMessages to selected messages of first message viewer
	repeat with cm in curMessages
		if exists (headers of cm whose name is "X-Delivered-To") then -- The intended recipient alias is saved in this header
			set theAccount to content of (first header of cm whose name is "X-Delivered-To")
		else -- Just put in an address from the account
			set theAddresses to email addresses of account of mailbox of cm
			set theAccount to first item of theAddresses
		end if
		get theAccount
		set theReply to reply cm with reply to all and opening window
		set sender of theReply to theAccount
	end repeat
end tell

The problem here is that theReply remains undefined. When I send a tell application “Mail” to get all outgoing messages, I get the confusing response of {Application “Mail”}. (Same bug noted here, which doesn’t contain a response.)

Any thoughts on how to get around this? I’ve tried changing the reply cm… statement to include properties {sender:theAccount}, but that doesn’t seem to work. I can’t attach properties to a reply command.


Its my first post here but I was working on this same issue the toher day, I figured out the Entourage method rather quickly but the mail took me a while to figure out why it was doing what it was doing. Here is what I ended up with.

tell application "Mail"
		set sender1 to make outgoing message with properties {subject:"yada yada", content: "insert message here"}
		tell sender1 to make new to recipient with properties {address:""}
		send sender1
end tell

for some reason you need to add the address in a separate row. go fig.

Model: PMG5 DP 2.5 GHZ
AppleScript: 1.10.6
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)

Err… That isn’t the problem at all. :confused:

The problem is with the “reply” function, which creates an unidentifiable outgoing message. Furthermore, I’m trying to create a message with a certain “from” address, not a “to” address.

I appreciate your attempts to help and all, but you might want to TRY the script sample provided before offering solutions. It’s just polite.

Happy scripting! :smiley:

I’m too having this problem. Keep getting error -2753 (the variable is not defined). :frowning: