Python comtypes read Outlook file

514 views Asked by At

I'm using comptypes python 3.6 and trying read office documents as i need to extract the text from these files.

I understand that for word and ppt this is how to open files using comtype

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

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

How about for Outlook files (.msg)? I tried the following code but doesn't work

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

There are 1 answers

0
mtryingtocode On BEST ANSWER

I've resorted in using the approach done in this thread instead of what I was testing out on my question.