Try using a real list of the selected messages by using a variable. For example:
tell application “Mail”
set the_sel to (selection)
repeat with this_sel in the_sel
set this_subject to (subject of this_sel)
display dialog this_subject
end repeat
end tell
If there is a ‘selection’ property for a certain application, then it’s usually a threaded list (each item is seen individually). After you set a variable to it, it becomes a real list. Sometimes you may want to use the threaded list. For instance, you may want a command to work on many items and the command doesn’t work on lists.
I’m not sure if this is what is happening in Mail. Sometimes it could be that you just need parenthesis. For repeat loops I ususally set a variable first.