title: Get mail subject using applescript
body: <p>I'm writing a script using the Mail applescript template (File > New from template > Mail > Mail Rule Action.scptd) but it doesn't seem like the examples in the template are working</p>
  
  <pre><code>using terms from application "Mail"
        on perform mail action with messages these_messages for rule this_rule
                  tell application "Mail"
                            set the message_count to the count of these_messages
                            repeat with i from 1 to the message_count
                                      set this_message to item i of these_messages
                                      try
                                                set this_subject to (subject of this_message) as Unicode text
                                                if this_subject is "" then error
                                      on error
                                                set this_subject to "NO SUBJECT"
                                      end try
                              say this_subject
                            end repeat
                  end tell
        end perform mail action with messages
  end using terms from
  </code></pre>
  
  <p>It says "no subject" even if the message has a subject. I'm using OS X 10.7.2 and Mail 5.1. Any suggestions?</p>