Connect to Exchange mailbox with Python(使用 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 邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Python 连接到 Exchange 邮箱


基础教程推荐
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 筛选NumPy数组 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01