Passing TextEdit value into AppleScript

Hi, guys,

I used to use this function before but I totally forgot how to do it. I need to pass the value of the TextEdit field into the applescript.

I need to pass the recipient’s name, email address and the subject into the following AppleScript. Thank you in advance.

Val


set recipientName to "WhiteHat"
set recipientAddress to "someemail@here.com"
set theSubject to "Type your subject here!"
set theContent to "Type your message content here!"

tell application "Mail"

        ##Create the message
        set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}

        ##Set a recipient
        tell theMessage
                make new to recipient with properties {name:recipientName, address:recipientAddress}

                ##Send the Message
                send

        end tell
end tell

What have you tried that hasn’t worked?

By the way, you can create an email without using AppleScript that goes to the user’s default mail client using a well formatted ShowURL and a mailto: link. It won’t auto-send, but you shouldn’t auto-send from an email client that’s not yours anyway - the user could be using a different email account than they want you to send with.

you need to wrap the entire script in an “on run” handler
and you pass it a bunch of arguments for the various bits

see http://developer.xojo.com/applescripts

Hi, Norman,

Thank you for the reply. I have the following XOJO app to practice passing the variables. In the main window in XOJO I have two TextFields and a PushButton.

I have the following code in the PushButton action:


saytextnew(TextField1.Text, TextField2.Text)

In the AppleScript I have the following script


on run {TextField1Text, TextField2Text}
	
	say TextField1Text
	
	delay 2
	
	say TextField2Text
	
	
end run

I do not know why but when the app is run it says the message in the TextField1 two times and it ignores the argument passed from the TextField2.

I am not sure what I am doing wrong.

Thank you and all others for help.

Val

Can you post an example?

try this
it works here

http://great-white-software.com/miscellaneous/applescript.zip