Simply creating and sending a message in

For some reason, geturl is returning NSCannotCreateScriptCommandError when I try to create a message in AS for

Can someone please post a line of script that works to create a mail message?


You don’t say which OS, but in 10.3.4, the following works for me:

set the_sub to "My automatic Message"
set the_sender to ""

tell application "Mail"
	set k to make new outgoing message with properties {subject:the_sub, content:the_message}
	tell k to make new to recipient at end of to recipients with properties {address:the_sender}
	send k
end tell

Not to be picky or anything, but I don’t see the_message being defined in that code.

set the_message to "Hello, the message goes here."

might help a bit. :slight_smile:

Hi chaps

This looks like the kind of code I’m looking for to launch the Mail app from a flash movie.

Could you let me know if I did not wnat it to send the email automatically and for it to just bring up the email application with the fields populated will it work if I just remove the send k command or do I need to do something different.

Any help appreciated.


Yeah, the “send” line can just be taken out. That should do it. Also:

display dialog "Would you like an auto-send?" buttons {"OK", "No K!"} default button 1
set x to (the button returned of the result) as string
if x is "OK" then
	set send_yes to "sure"
	set send_yes to "no_way"
end if

Then, try replacing the send part with this:

if send_yes is "sure" then
	send k
	-- do not send the message :(
	-- doing this will allow you to edit the message/fields
end if

That’s a more “advanced” where, on run, gives you an option of whether you want to send the message automatically, or edit/ and do it manually.

And yes, all, I’m still alive, I’ve just been busy with school :slight_smile: Thus, excuse all my “syntax rustiness” please.

– ashanks
if Macs is made by Apple then
display dialog “Rock On Dudes!”
display dialog “Oh no! :o”
end if

Yes, the send is optional. Instead you can save it to the Drafts folder, or simply open a window so the user can edit (in which case you need to make it visible), or both:

set {theSubject, theText, theRecipient} to {"Test eMail", "The quick brown fox jumped over the lazy red dogs.", ""}

tell application "Mail"
	set theMessage to make new outgoing message with properties {subject:theSubject, content:theText}
	tell theMessage
		make new to recipient at end of to recipients with properties {address:theRecipient}
		set visible to true -- optional (shows the newly created eMail in a window)
		save -- optional (saves it in the "Drafts" folder)
	end tell
end tell