connect-to-exchange-mailbox-with-python/3072491 ....我已经推荐以下链接连接到Exchange Online并下载附件并在Windows上阅读邮件(使用Python和exchangelib库)。现在我想在CentOS上完成相同的任务,但是当我手动下载exchangelib
库并安装它时。 每当我试图导入exchangelib,它会引发如下错误:从Microsoft Exchange Server读取电子邮件并下载附件
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "exchangelib/__init__.py", line 2, in <module>
from .account import Account # noqa
File "exchangelib/account.py", line 8, in <module>
from cached_property import threaded_cached_property
ImportError: No module named cached_property
可能是什么问题?
我的主要目标是阅读电子邮件并下载它们。没有imap/pop3服务器地址可用。是否有替代exchangelib
?
from exchangelib import DELEGATE, Account, Credentials
credentials = Credentials(
username='MYWINDOMAIN\\myusername',
password='topsecret'
)
account = Account(
primary_smtp_address='[email protected]',
credentials=credentials,
autodiscover=True,
access_type=DELEGATE
)
# Print first 100 inbox messages in reverse order
for item in account.inbox.all().order_by('-datetime_received')[:100]:
print(item.subject, item.body, item.attachments)
我在Windows中使用了这段代码。用Linux帮助我。
为什么这标题与标题中的centos/centos?它似乎不是具体的centos。 –