python如何读取outlook邮件_通过MAPI使用Python从Outlook中阅读电子邮件

通过MAPI使用Python从Outlook中阅读电子邮件

我试图编写一个简短的程序,将读取我的Exchange / Outlookconfiguration文件中的文件夹内的电子邮件内容,以便我可以操纵数据。 不过,我有一个问题,find有关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 ()

但是我得到一

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值