How do I download only unread attachments from a specific gmail label?

前端 未结 1 922
礼貌的吻别
礼貌的吻别 2021-02-02 04:38

I have a Python script adapted from Downloading MMS emails sent to Gmail using Python

import email, getpass, imaplib, os

detach_dir = \'.\' # directory where to         


        
相关标签:
1条回答
  • 2021-02-02 04:46

    Try modifying this line:

    resp, items = m.search(None, 'FROM', '"Impact Stats Script"')
    

    to:

    resp, items = m.search(None, 'UNSEEN', 'FROM', '"Impact Stats Script"')
    

    The Python imaplib documentation shows just adding more search criteria, and the IMAP specification defines the UNSEEN search criteria:

      UNSEEN
         Messages that do not have the \Seen flag set.
    
    0 讨论(0)
提交回复
热议问题