-2

I received some email flaged seen with mail_status="UNSEEN".Below is my code.I would be very grateful if you could help me.

def get_email(self, mail_index=None,  mail_status="UNSEEN", mailbox="INBOX"):       
    self.imap_client.select(mailbox,readonly=False)
    _, dat = self.imap_client.search(None, mail_status)
   if not dat\[0\]:
       raise RuntimeError("not email")

    if mail_index is None:
        mail_index = dat[0].decode("utf-8").split(" ")[-1]
    mail_index = str(mail_index)
    #@patch:some seen email appear
    self.is_may_seen_before=False
    if self.is_email_seen(mail_index):
        self.is_may_seen_before=True
    
    _, dat = self.imap_client.fetch(mail_index, '(RFC822)')
    dat_obj = ParseEmail(dat[0][1])
    
    return dat_obj

def is_email_seen(self, mail_index):
   try:
        _, status = self.imap_client.fetch(mail_index, '(FLAGS)')
        return "\\Seen" in status\[0\].decode()
    except Exception as e:
        del_err(e)
        return False
king
  • 1
  • 1
    This does not look like valid Python code. Please review the guidance for providing a [mre]. – tripleee Aug 18 '23 at 15:46
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 18 '23 at 18:11

0 Answers0