title: AppleScript Error: Mail got an error: Unrecognized direct parameter type, please specify a string like "John Doe <jdoe@example.com>"
body: <p>I have a script that filters emails based on the <code>to recipient</code> but I'm getting an error.</p>
  <p>This is the script:</p>
  <pre><code>tell application &quot;Mail&quot;
      set firstInboxMessage to the first message of mailbox &quot;INBOX&quot; of account &quot;Account&quot;
      set theEmail to extract address from to recipient of the firstInboxMessage
      set my text item delimiters to {&quot;+&quot;, &quot;@&quot;}
      set mailboxName to text item 2 of theEmail
      set messageAccount to account of mailbox of the firstInboxMessage
      tell the messageAccount to if the name of its mailboxes does not contain ¬
          the mailboxName then make new mailbox at the end of its mailboxes ¬
          with properties {name:mailboxName}
      set newMailbox to the mailbox named mailboxName in the messageAccount
      set the mailbox of the firstInboxMessage to the newMailbox
  end tell
  </code></pre>
  <p>And this is the error:</p>
  <pre><code>Mail got an error: Unrecognized direct parameter type, please specify a string like &quot;John Doe &lt;jdoe@example.com&gt;&quot;
  </code></pre>
  <p>I think it has to do with the fact that <code>to recipient</code> is classified differently somehow in AppleScript compared to for example <code>subject</code> or <code>sender</code> because when I use either of those the script runs fine.</p>
  <p>Any help would be greatly appreciated.</p>