Applescrript from Rev

Sarah Reichelt sarah.reichelt at gmail.com
Sat Jan 9 02:19:38 EST 2010


> on mac OS X(leopard)
> I'd like do send an applescript from rev to mail.app
> it should be something like this :
> open mail.app
> open a new message
> fill the fields "To", "Object" and "Message" with variables


Here is the script I use:

Here is the Rev part, fill in the recipVar, subjectVar and bodyVar
variables as required:

    put the cMakeEmail of this stack into makeEmail
    replace "*addr*" with quote & recipVar & quote in makeEmail
    replace "*subj*" with quote & subjectVar & quote in makeEmail
    replace "*body*" with quote & bodyVar & quote in makeEmail
    do makeEmail as AppleScript

And here is the AppleScript that I store in a custom property of the
stack, called cMakeEmail:

tell application "Mail"
	activate
	copy *addr* to recipVar
	copy *subj* to subjVar
	copy *body* to bodyVar
	
	set newMessage to make new outgoing message with properties
{subject:subjVar, content:bodyVar & return & return}
	tell newMessage
		set visible to true
		make new to recipient at end of to recipients with properties
{address:recipVar}
	end tell
end tell

This is a very basic AppleScript that just assumes a single recipient
and no attachments, but it should be enough to get you started anyway.
If the body of the email contains any quotes, you need to escape them,
or replace them with single quotes first.

Regards,
Sarah



More information about the use-livecode mailing list