title: How to find uid of existing python email object
body: <p>I have been reading through <a href="http://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/" rel="nofollow">this document</a>. Most of the document is based on finding an email's uid. From the article:</p>
  
  <pre><code>"The way this works is pretty simple: use the uid function, and pass in the string of the command in as the first argument. The rest behaves exactly the same.
  
  result, data = mail.uid('search', None, "ALL") # search and return uids instead
  latest_email_uid = data[0].split()[-1]
  result, data = mail.uid('fetch', latest_email_uid, '(RFC822)')
  raw_email = data[0][1]
  </code></pre>
  
  <p>I'm working with a django app called django-mailbox (<a href="http://django-mailbox.readthedocs.org/en/latest/index.html" rel="nofollow">http://django-mailbox.readthedocs.org/en/latest/index.html</a>) the purpose of which is to consume emails.</p>
  
  <p>The app creates a "Message" model that looks like:</p>
  
  <pre><code>u'django_mailbox.message': {
          'Meta': {'object_name': 'Message'},
          'body': ('django.db.models.fields.TextField', [], {}),
          'encoded': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
          'from_header': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
          u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
          'in_reply_to': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'replies'", 'null': 'True', 'to': u"orm['django_mailbox.Message']"}),
          'mailbox': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'messages'", 'to': u"orm['django_mailbox.Mailbox']"}),
          'message_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
          'outgoing': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
          'processed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
          'read': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
          'subject': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
          'to_header': ('django.db.models.fields.TextField', [], {}) 
  </code></pre>
  
  <p>using the python "email" library I can select a record from a django queryset and turn it into an email object:</p>
  
  <pre><code>qs = Message.objects.filter("my criteria")
  first = qs[0]
  one = first.get_email_object() // one is an email object
  </code></pre>
  
  <p>Does the existing data in the db have a uid,  and if so how can I grab it. </p>