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
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.
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.