我在尝试循环浏览电子邮件收件箱时遇到问题。我以前可以使用我写的东西,但是自从重新安装ExchangeLib之后,我现在抛出了一个错误。这是我到目前为止的情况。你知道吗
from exchangelib import Credentials, Account
from bs4 import BeautifulSoup
credentials = Credentials('my@email', 'password')
account = Account('my@email', credentials=credentials, autodiscover=True)
my_inbox = account.inbox
for item in my_inbox.all()[:1]:
html = item.unique_body
soup = BeautifulSoup(html, "html.parser")
for span in soup.find_all('font'):
return(item.subject, item.sender.email_address, span.text)
print(item.subject, item.sender.email_address, span.text)
我希望能做的是访问我的收件箱,返回第一封邮件的主题行、发件人电子邮件和正文(必须通过BeautifulSoup,因为item.u体是所有HTML标记)。但目前什么也没印。我有打印语句作为测试,但会删除它时,它是工作。你知道吗
另外,我不断得到一个错误,即“Method'inbox'没有'all'成员,引用my_inbox.all()
。我也不知道为什么它不起作用,因为它是工作的前几天。你知道吗
有什么帮助吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐