Sending mail

When I run the following script, the message is created and I can see it open on the screen.

tell application Mail
	set newMessage to make new outgoing message
	tell newMessage
		set subject to "Email Received"
		set content to messageBody
		set visible to true
		set sender to "Notification Service"
		make new to recipient at end of to recipients with properties {name:"Mark Ashley", address:""}
	end tell
end tell

If I change activate to send, then I hear the sound Mail makes when it sends a message, but the message doesn’t go in to the Sent box and the message never arrives.

What am I doing wrong?


Hmm… works fine here, Mark - obviously with personal details changed (and “Mail” quoted).

That ‘sender’ property seems a bit suspect to me - since it doesn’t look like a valid account. If I try to use “Notification Service” in the same way, it shows up as red in the Account pop-up menu of the new message (indicating an email account in a domain that isn’t “safe”). The send fails under these conditions. :confused:

Ahhh yes, it was the Sender property that was causing it. I thought this would change the “From” field on the recipient’s email.

I’ve removed the line and it’s working now - thanks very much.