title: How to fetch last 10 messages from IMAP server?
body: <p>I use imaplib2 library to search the last 10 messages with such command: </p>
  
  <pre><code>imap_client.search(None, '{}:{}'.format(last_uid, last_uid - 9))
  </code></pre>
  
  <p>But to get <code>last_uid</code> I need exec every time command like this:</p>
  
  <pre><code>imap_client.select("INBOX", readonly=True)
  </code></pre>
  
  <p>to get last UID.</p>
  
  <p>Are the any ways to:</p>
  
  <ol>
  <li>get last UID without <code>select()</code> command fetch last 10 messages</li>
  <li>without last UID. Maybe there are any search criterias like 'LAST' or '-10:'?</li>
  </ol>
  
  <p>I can not exec command like this <code>client.search(None, 'ALL')</code>, because IMAP server have more than 50K messages. </p>