使用Python连接到Exchange邮箱 [英] Connect to Exchange mailbox with Python

查看:6287
本文介绍了使用Python连接到Exchange邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以Python脚本连接到Exchange邮箱,而无需在本地计算机上使用任何配置文件设置(包括使用Outlook)。如果我使用win32com创建一个MAPI.Session,我可以登录(使用Logon()方法)与现有的配置文件,但我想提供一个用户名&密码。

I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing profile, but I want to just provide a username & password.

这可能吗?如果是这样,有人可以提供示例代码吗?我宁愿如果它只使用标准库和pywin32包。不幸的是,为Exchange服务器启用IMAP访问(然后使用imaplib)是不可能的。

Is this possible? If so, could someone provide example code? I would prefer if it only used the standard library and the pywin32 package. Unfortunately, enabling IMAP access for the Exchange server (and then using imaplib) is not possible.

如果有必要:所有脚本都将连接到邮箱,并通过收件箱中的邮件运行,检索内容。我可以处理编写代码,如果我可以得到一个连接在第一个地方!

In case it is necessary: all the script will be doing is connecting to the mailbox, and running through the messages in the Inbox, retrieving the contents. I can handle writing the code for that, if I can get a connection in the first place!

澄清有关Outlook:Outlook将安装在本地机器上,但它没有任何帐户设置(即所有适当的库将可用,但我需要独立于任何设置内部的Outlook操作)。

To clarify regarding Outlook: Outlook will be installed on the local machine, but it does not have any accounts setup (i.e. all the appropriate libraries will be available, but I need to operate independently from anything setup inside of Outlook).

推荐答案

我确定这将是不可能的,不使用Outlook和MAPI配置文件。如果你可以甜蜜地谈论你的邮件管理员在Exchange服务器上启用IMAP,这将使你的生活更容易。

I'm pretty sure this is going to be impossible without using Outlook and a MAPI profile. If you can sweet talk your mail admin into enabling IMAP on the Exchange server it would make your life a lot easier.

这篇关于使用Python连接到Exchange邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆