Python comtypes 读取 Outlook 文件

Python comtypes read Outlook file

我正在使用 comptypes python 3.6 并尝试阅读办公文档,因为我需要从这些文件中提取文本。

我知道对于 word 和 ppt,这是使用 comtype 打开文件的方法

word = comtypes.client.CreateObject('Word.Application')
doc = word.Documents.Open(filename)

ppt = comtypes.client.CreateObject('PowerPoint.Application')
prs = ppt.Presentations.Open(filename)

Outlook 文件 (.msg) 怎么样?我尝试了以下代码但不起作用

ol = comtypes.client.CreateObject('Outlook.Application')
msg = ol.MailItem.Open(filename)

我使用了这个 thread 中完成的方法,而不是我在我的问题上测试的方法。