欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

python如何读取weboutlook内容_用Python通过MAPI读取Outlook中的电子邮件

发布时间:2023/12/20 52 豆豆
生活随笔 收集整理的这篇文章主要介绍了 python如何读取weboutlook内容_用Python通过MAPI读取Outlook中的电子邮件 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

我正在尝试编写一个简短的程序,该程序将读取exchange/Outlook配置文件中某个文件夹中电子邮件的内容,以便可以操作数据。但是,我在查找有关python和exchange/Outlook集成的许多信息时遇到问题。很多东西不是很旧/没有文档/没有解释。我试过几个片段,但似乎也有同样的错误。我试过Tim Golden的密码:import win32com.client

session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")

#

# Leave blank to be prompted for a session, or use

# your own profile name if not "Outlook". It is also

# possible to pull the default profile from the registry.

#

session.Logon ("Outlook")

messages = session.Inbox.Messages

#

# Although the inbox_messages collection can be accessed

# via getitem-style calls (inbox_messages[1] etc.) this

# is the recommended approach from Microsoft since the

# Inbox can mutate while you're iterating.

#

message = messages.GetFirst ()

while message:

print message.Subject

message = messages.GetNext ()

但是我得到一个错误:pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

不确定我的个人资料名称,所以我尝试了:session.Logon()

提示,但也不起作用(同样的错误)。同时尝试打开和关闭Outlook,但都没有改变任何内容。

总结

以上是生活随笔为你收集整理的python如何读取weboutlook内容_用Python通过MAPI读取Outlook中的电子邮件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。