tell application "Mail" set fullAcctNames to mailboxes of accounts of application "Mail" set acctBoxes to {} set fullAcctNamesList to {} repeat with j from 1 to number of items in fullAcctNames repeat with i from 1 to number of items in item j in fullAcctNames copy item i in item j of fullAcctNames to the end of fullAcctNamesList set this_item to the name of item i in (item j of fullAcctNames) set acctName to the name of account of item i of item j in fullAcctNames copy acctName & " " & this_item to the end of acctBoxes end repeat end repeat set fullBoxNames to mailboxes of application "Mail" set localBoxes to {} repeat with i from 1 to number of items in fullBoxNames set this_item to the name of item i of fullBoxNames copy this_item to the end of localBoxes end repeat set allBoxes to localBoxes & acctBoxes copy "INBOX" to the end of allBoxes --copy "Outbox" to the end of allBoxes copy "Sent" to the end of allBoxes copy "Trash" to the end of allBoxes end tell set myPrompt to ("What mailbox do you want ?") tell application "SpeechRecognitionServer" set theResult to (listen for allBoxes with prompt myPrompt displaying allBoxes) say "You have chosen " & theResult if theResult is "Outbox" then tell application "Mail" set selected mailboxes of the front message viewer to {outbox} end tell end if -- get the actual mailbox name from the spoken response repeat with i from 1 to number of items in localBoxes set this_item to item i of localBoxes if theResult is equal to item i of localBoxes then set theResult to item i of fullBoxNames end repeat repeat with i from 1 to number of items in acctBoxes set this_item to item i of acctBoxes if theResult is equal to item i of acctBoxes then set theResult to item i of fullAcctNamesList end repeat end tell tell application "Mail" activate try if theResult is "INBOX" then set selected mailboxes of the front message viewer to {inbox} else if theResult is "Drafts" then set selected mailboxes of the front message viewer to {drafts mailbox} else if theResult is "Sent" then set selected mailboxes of the front message viewer to {sent mailbox} else if theResult is "Trash" then set selected mailboxes of the front message viewer to {trash mailbox} else set selected mailboxes of the front message viewer to {theResult} end if on error the error_message number the error_number -- don't display error message if the user canceled a dialog within the [try] and [on error] lines above if the error_number is not -128 then set the error_text to "Error: " & the error_number & ". " & the error_message display dialog the error_text buttons {"Cancel"} default button 1 else error number -128 end if end try end tell