Applescript: mail from account, access not allowed

I’m using applescript and Apple mail to send email, I need it sent from a specific account and I’m having trouble setting the from account or sender:

set account to account "Google"

gives me this error:

224:242: syntax error: Can’t set «class mact» to «class mact» “Google”. Access not allowed. (-10003)

I have verified that the account exists, I get the same error with:

set account to the first account
set sender to "<my email address>"

doesn’t affect the sender in any way that I can see.

Any help or suggestions?

(Yosemite)

thanks

full code:

tell application "Mail"
		tell (make new outgoing message )
			set subject to "subject"
			set content to "Add your message here\n\n"
			set visible to true
			-- set sender to "<my email account>"
			set account to account "Google"
			make new to recipient at end of to recipients with properties {address:"$mailTo", name:"Name" }
		end tell
	end tell

Hi,

outgoing message has no account property, the account is specified by the sender


tell application "Mail"
	tell (make new outgoing message with properties {visible:true, subject:"subject", content:"Add your message here\n\n"})
		set sender to "John Doe <john@doe.com>"
		make new to recipient at end of to recipients with properties {address:"$mailTo", name:"Name"}
	end tell
end tell

OK, thanks. But setting ‘sender’ isn’t changing anything. The mail ‘from’ remains whatever the default is in Mail. I have a couple of personal accounts and a google account in Mail, I’d like for mail to be sent as from the google one. Make sense?

OK, I have it. It’s, obviously, very picky about the value of the string; if it’s not right it quietly sets sender to the first account in the list.

Thanks for you input.

K.

outgoing message is an element of the application regardless of the account
Did you specify the sender with the syntax “name ” ?