【发布时间】:2022-09-27 13:09:55
【问题描述】:
我想接收来自特定发件人的所有今天的电子邮件文本,并使用 imap-tools 将它们放入 Outlook 的列表中
我做了以下功能,但问题是它不会从上午 12:00 到下午 12:00 检索电子邮件,有没有办法指定获取正确消息的时间?
def get_emails(username, password, sender):
from imap_tools import MailBox, A
emails = []
with MailBox(\'outlook.office365.com\').login(username, password, \'INBOX\') as mailbox:
for msg in mailbox.fetch(
A(
A(date_gte=datetime.date.today()), # get the today\'s emails
A(from_=sender), # from the specific senderEmailAddress
),
mark_seen = True
):
if msg.subject == \"Subject\":
emails.append(msg.text)
return emails
标签: python imap-tools