Skip to content

Instantly share code, notes, and snippets.

@ecarreras
Created July 7, 2016 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecarreras/21bbe5819099b4b474824692b5abbbfd to your computer and use it in GitHub Desktop.
Save ecarreras/21bbe5819099b4b474824692b5abbbfd to your computer and use it in GitHub Desktop.
for i in range(rec.last_mail_id + 1, int(msg_count[0]) + 1):
if rec.rec_headers_den_mail:
typ, msg = serv.fetch(str(i), '(FLAGS BODY.PEEK[HEADER])')
method = getattr(self, 'save_header')
else:
typ, msg = serv.fetch(str(i), '(FLAGS RFC822)')
method = getattr(self, 'save_fullmail')
for mails in msg:
if type(mails) == type(('tuple', 'type')):
mail = email.message_from_string(mails[1])
ctx = context.copy()
if '\Seen' in mails[0]:
ctx['state'] = 'read'
if method(cr, uid, mail, id, mails[0].split()[0], ctx):#If saved succedfully then increment last mail recd
self.write(cr, uid, id, {'last_mail_id':mails[0].split()[0]}, context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment