python imaplib search with multiple criteria
<p>I'm trying to use the search function and am running into an issue. I can download all attachments from a gmail account and sort them according to the file extension. I have all of that code working right except when I add extra criteria to the search. Originally the search criteria was only for UNSEEN emails, which works and then flags the email as seen and moves it to the trash. I then decided to add to it. Here is the example:
original:</p>

<pre><code>resp, items = m.search (None, 'UNSEEN') 
</code></pre>

<p>new:</p>

<pre><code>resp, items = m.search (None, '(FROM "email" SUBJECT "some text")', 'UNSEEN')
</code></pre>

<p>It results with the emails moved to the trash, still unread and none of the attachments downloaded. Anyone have any idea what I may be doing wrong here? Thanks.</p>