title: Process only some messages from a message queue
body: <p>I have a message queue where i add some emails.
  I want to extract all emails, examine the date when they were added and their priority and send only one of them.
  I read messages like this:</p>
  
  <pre><code>private IList&lt;Email&gt; GetEmailsFromQueue(MessageQueue queue)
  {
      queue.Formatter = new XmlMessageFormatter(new Type[] { typeof(Email) });
      IList&lt;Email&gt; emails = new List&lt;Email&gt;();
      Cursor cursor = queue.CreateCursor();
      Message m = PeekWithoutTimeout(queue, cursor, PeekAction.Current);
      if (m != null)
      {
          emails.Add((Email)m.Body);
          while ((m = PeekWithoutTimeout(queue, cursor, PeekAction.Next)) != null)
          {
              emails.Add((Email)m.Body);
          }
      }
      return emails;
  }
  
  private Message PeekWithoutTimeout(MessageQueue q, Cursor cursor, PeekAction action)
  {            
      Message msgFromQueue = null;
      try
      {
          msgFromQueue = q.Peek(new TimeSpan(1), cursor, action);
      }
      catch(MessageQueueException ex)
      {
          if (!ex.Message.ToLower().Contains("timeout"))
          {
              throw;
          }
      }
      return msgFromQueue;
  }
  </code></pre>
  
  <p>Receive method will remove the message from the queue.
  Is there any way to read and remove only some messages?</p>
  
  <p>LE: One solution i mighty think of is to add an id to each message, and use ReceiveById</p>
  
  <p>Any other tips?</p>