21

How can I parse and read an outlook pst file in Python?

demos
  • 2,630
  • 11
  • 35
  • 51
  • 9
    I wasted several days finding a reliable way to do that, so the initial question was definitively a good question! I'd like the item reopened so that I can post the solution I found eventually, using the win32com.client library, available in standard Python distributions for Windows. – Jean-François Larvoire Jan 30 '17 at 17:52
  • 1
    @Jean-FrançoisLarvoire could you point to a resource or some documentation for the solution you found? – TrigonaMinima Feb 27 '18 at 07:04

2 Answers2

17

pypff is a python wrapper for the C library libpff that allows you to access email and the directory structure of Pst files within python.

Do a make of the library with the specified command to install the python bindings. Then you should be able to open up the python console and browse through Pst files.

import pypff

pst = pypff.file()
pst.open("MyPst.pst")
pst.close()

There are more examples on the libraries website. However, I found that there wasn't enough functionality in the library yet. For instance, you can read emails and the directories, but there isn't anything for attachments yet.

kslote1
  • 720
  • 6
  • 15
7

I have only ever poked at libpst docs, but it looks like the libpst-python package might work for you: libpst-python

dreynold
  • 865
  • 8
  • 17