Example #1
0
 def get_message(self, uid):
     """ Return an ImapMessage object created from the message with UID.
         Raise KeyError if there if there is no message with that UID.
     """
     rfc822string = self._cache_message(uid)
     result = ImapMessage(rfc822string)
     result.set_imapflags(self.get_imapflags(uid))
     result.internaldate = self.get_internaldate(uid)
     result.size = self.get_size(uid)
     if self._factory is ImapMessage:
         return result
     return self._factory(result)
Example #2
0
 def get_header(self, uid):
     """ Return an ImapMessage object containing only the Header
         of the message with UID.
         Raise KeyError if there if there is no message with that UID.
     """
     (code, data) = self._server.uid('fetch', uid, "(BODY.PEEK[HEADER])")
     if code != 'OK':
         raise ImapNotOkError("%s in fetch_header(%s)" % (code, uid))
     try:
         rfc822string = data[0][1]
     except TypeError:
         raise KeyError("No UID %s in get_header" % uid)
     result = ImapMessage(rfc822string)
     result.set_imapflags(self.get_imapflags(uid))
     result.internaldate = self.get_internaldate(uid)
     result.size = self.get_size(uid)
     if self._factory is ImapMessage:
         return result
     return self._factory(result)