I created an email script in AppleScript, but it is not working.(Read below as well)

I created an email script in AppleScript.
Here is the code:
set recipentNamePrompt to display dialog "What is the name of the recipient?" default answer "Cookie Monster"
set recipientAddressPrompt to display dialog "What is the email of the recipient?" default answer "[email protected]"
set subjectPrompt to display dialog "What is the subject of the email?" default answer "Change Cookie Recipe"
set contentPrompt to display dialog "What would you like to put in your message?" default answer "Cookie Monster want MORE chocolate chips in cookies!"
set recipientName to recipentNamePrompt
set recipientAddress to recipientAddressPrompt
set theSubject to subjectPrompt
set theContent to contentPrompt
--Mail Tell Block
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
But when I type in my info, the created message is written in Chinese. Someone please help me!

The result of a display dialog is a record that contains the properties button returned, text returned (if default answer is used), and gave up (if giving up after is used).  Since you are passing the entire record to the Mail fields, it looks like it is getting interpreted as some Unicode text.  The solution is to get rid of your intermediate prompt variables and just get the desired property (the text returned), for example:
set recipientName to text returned of (display dialog "What is the name of the recipient?" default answer "Cookie Monster")
set recipientAddress to text returned of (display dialog "What is the email of the recipient?" default answer "[email protected]")
set theSubject to text returned of (display dialog "What is the subject of the email?" default answer "Change Cookie Recipe")
set theContent to text returned of (display dialog "What would you like to put in your message?" default answer "Cookie Monster want MORE chocolate chips in cookies!")

Similar Messages

Maybe you are looking for