下面返回看不见的电子邮件及其各自的主题行。如何只返回与关键字匹配的看不见的电子邮件主题行?
任何帮助将不胜感激,非常感谢提前....
import email
from imapclient import IMAPClient
HOST = 'somthin.com'
USERNAME = 'email'
PASSWORD = 'pwd'
with IMAPClient(HOST) as server:
server.login(USERNAME, PASSWORD)
server.select_folder("INBOX", readonly=True)
messages = server.search("UNSEEN")
for uid, message_data in server.fetch(messages, "RFC822").items():
email_message = email.message_from_bytes(message_data[b"RFC822"])
print(uid, email_message.get("Subject"))