Choosing options from a drop-down menu

Related to my other question (it’s about replying to mail) but more complex…

I have to reply to literally hundreds of emails a day. But the number of different replies is about ten.

Dear whoever, product no longer available; Dear whoever, product available in June; Dear whoever, please refer such-and-such a page.

What I’d like, ideally, is to have a dialog appear which let me choose from ten answers, then hit OK and have my selected answer used.

The only thing I can do in regular AppleScript is a dialog with buttons – or of course come up with ten variations on the same script. Do I have to now explore AppleScript Studio in order to get the dialog and the menu?

Any ideas, sample code, examples, pointers etc gratefully received.

You could create a list of the ten responses and then use an if statement to process the choice, like so:

set theReplies to {"boilerplate 1", "boilerplate 2", "boilerplate 3"}
set theChoice to (choose from list theReplies) as text
set thisReply to processChoice(theChoice)
set theMessage to "Dear " & (text returned of (display dialog "enter name" default answer "")) & ", 

" & thisReply

on processChoice(thisChoice)
	if thisChoice is "boilerplate 1" then
		set theText to "product no longer available"
	else if thisChoice is "boilerplate 2" then
		set theText to "product available in June"
	else if thisChoice is "boilerplate 3" then
		set theText to "please refer such-and-such a page"
	end if
	return theText
end processChoice

Hi,

Use the choose from list command. There are various ways of creating your list conveniently.

property reply_list : {“reply1”, ¬
“reply2”, ¬
“reply3”}
set this_reply to item 1 of (choose from list reply_list)

gl,

Thanks for that, it’s working already. I had no idea I could get a menu-dialog like that. Great stuff.