当前,我使用以下方法读取Gmail帐户中具有给定主题(即subjectStr)的电子邮件数量:
self.mail = imaplib.IMAP4_SSL('imap.gmail.com')
self.mail.login(username, password)
self.mail.list()
self.mail.select("inbox")
subjectStr = '(HEADER Subject ' + "\"" + mySubject + "\"" + ')'
result, UIDemailsWithGivenSubject = self.mail.uid('search', None, subjectStr)
ids_string = UIDemailsWithGivenSubject[0].decode("utf-8")
ids_string_list = ids_string.split(" ")
if ids_string == "":
self.numUIDsWithSubject = 0
else:
self.numUIDsWithSubject = len(ids_string_list)
我有几个发件人都向具有相同主题的同一gmail帐户发送电子邮件。我想知道从特定发件人或特定地址发送的电子邮件数量:self.xyzAdr我如何用另一句话来添加该条件:
self.mail.uid('search', None, subjectStr)
还需要检查发件人self.xyzAdr。