title: AppleScript and Mail.app: checking if new messages contain a string
body: <p>I'm writing a script to check if a particular web form has been submitted.</p>
  
  <p>The script so far reads thusly:</p>
  
  <pre><code>tell application "Mail"
  check for new mail
  set newmail to get the unread count of inbox
  repeat with msg in newmail
      if msg's subject contains "New newsletter built by" then
          return msg's subject
      end if
  end repeat
  end tell
  </code></pre>
  
  <p>I've got an unread email in my inbox for the script to work with, but I still get an error:</p>
  
  <pre><code>error "Mail got an error: Can’t make 1 into type specifier." number -1700 from 1 to specifier
  </code></pre>
  
  <p>Any help at all will be appreciated.</p>
  
  <p>Cheers!</p>