Python/exchangelib无法建立连接

2024-06-06 12:35:02 发布

您现在位置:Python中文网/ 问答频道 /正文

对不起,我的英语不太好: 在windows域中,我尝试使用pypi站点上给出的示例连接到exchangeserver(2010/SP3):

from exchangelib import DELEGATE, NTLM, Account, Credentials, Configuration
import os, logging

logging.basicConfig(level=logging.DEBUG)

creds = Credentials(
    username='mydomain\\my.name', 
    password='mypassword')

config = Configuration(server='exchange.xxx.local/EWS/Exchange.asmx', credentials=creds)

account = Account(
    primary_smtp_address='my.name@mycompany.com',
    credentials=creds,
    autodiscover=False,
    access_type=DELEGATE)

for item in account.inbox.all().order_by('-datetime_received')[:30]:
    print(item.subject, item.body, item.attachments)

启动脚本后,我在python控制台中得到以下输出:

^{pr2}$

我还尝试了exchangelib站点的其他选项,autodiscover=True,只有creds=given(没有config=)。没有成功。 然后,我从https://ewseditor.codeplex.com/安装了EWS编辑器,以查看通过EWS的连接在我公司的环境中是否有效。它可以很好地使用这个工具,只要给它我的SMTP地址。在

我将非常感谢你的帮助。提前谢谢!在


Tags: nameimportconfig站点myloggingaccountitem