And the winner is ...

Practical example of using AppleScript to generate a random number.

OS version:

tell application "Mail"
  set myfolder to "zBook giveaway"
  set mycount to the count of messages of mailbox myfolder
  set randNum to (random number from 1 to mycount)
  set mysender to sender of message randNum of mailbox myfolder as text
  display dialog "the winner is: " & mysender
  set the clipboard to mysender
end tell