trouble scripting mail

I’m stuck as to why this script isn’t working. The selections all work (which will ultimately fill in the body of the message). There are two things wrong:

  1. the subject result has parentheses around it, which I don’t want.

  2. More importantly, the “to” field will not get filled in and AS returns the error “Mail got an error: NSContainerSpecifierError”

Here’s the script:


set listRoom to {"Shaughnessy", "Garcia", "7013", "Events", "AV Loaner"}
set theRoom to choose from list listRoom with prompt "Which calendar would you like to add an event to?"


set theGroup to text returned of (display dialog "Enter the Office or Group that will be holding this event" default answer ("Front Office, Press Conference"))
set theContact to text returned of (display dialog "Enter a contact name and number for this event" default answer ("Montgomery Burns, x12345"))
set theDate to text returned of (display dialog "Enter date as mm/dd/yyyy" default answer (short date string of (current date)))
set the StartTime to text returned of (display dialog "Enter start time as hh:mm:ss AM" default answer (time string of (current date)))
set endTime to text returned of (display dialog "Enter end time as hh:mm AM" default answer (time string of (current date)))
set thePeople to text returned of (display dialog "How many people will be attending this event?" default answer "10")
set theNotes to text returned of (display dialog "Enter any notes for the event:" default answer " ")


set theRecipient to "email@mail.com" as text

tell application "Mail"
	activate
	set newMessage to make new outgoing message with properties {content:theGroup, subject:theRoom, visible:true}
	tell newMessage
		make new to recipient at end of to recipients with properties {name:"ICE TV", address:theRecipient}
	end tell
end tell


Thoughts? I’ll keep digging in the meantime…

Thanks,
Mike

Model: Mac Pro, Octo
AppleScript: 1.10.7
Browser: Firefox 2.0.0.11
Operating System: Mac OS X (10.4)

so in the 5 minutes since posting this, or course I fixed it. the result of my “choose from list” wasn’t text. so i added a line after the list that set the result to a variable as text.

is this normal for a choose from list? do i have to coerce it to text (if thats the right term) in order to use the result as a variable?

choose from list returns always a list
try this, it also aborts the script, if the user presses “Cancel”


.
choose from list listRoom with prompt "Which calendar would you like to add an event to?"
tell result
	if it is false then return
	set theRoom to item 1 of it
end tell
.

gotcha. my workaround is working fine (setting the selection to a new variable as text). but its good to know how lists work. :slight_smile: thanks.

.but if the user presses “Cancel”, the message will be created but the subject will be false :wink: