This script extracts all emails from an Outlook PST archive and saves them into some output folder as individual RFC822 compliant *.eml files.
Installing the external dependency pypff may not be straight forward (it wasn't for me). I forked the original repository to make it work in Python 3. If you get errors, check their wiki pages for help or try my fork. Below are the steps that worked for me:
Tested on MacOS with Python 3.6.
Install prereqs:
brew install autoconf automake libtool gettext
export PATH=$PATH:/usr/local/Cellar/gettext/0.20.1/binThen clone https://github.com/TimRepke/libpff
cd libpff/
./synclibs.sh
./autogen.sh
./configure --enable-python
python setup.py build
sudo python setup.py installAfter the binary has been built, create a new file in your build directory. Mine is libpff/build/lib.macosx-10.15-x86_64-3.6/pypff.py. Add the following boilerplate:
def __bootstrap__():
global __bootstrap__, __loader__, __file__
import sys, pkg_resources, imp
__file__ = pkg_resources.resource_filename(__name__,'pypff.cpython-36m-darwin.so')
__loader__ = None; del __bootstrap__, __loader__
imp.load_dynamic(__name__,__file__)
__bootstrap__()You can now import it as
>>> import pypffNow that everything is installed, you can execute the following script within the same folder as pypff.py
python3 pst2eml.py /path/to/archive.pst /path/to/output/dirOptionally, you can write the log into a file by adding --logfile=/path/to/log_dir to the command.
Full disclaimer: I was inspired by this script, but as you may see, I pretty much threw everything overboard and made my own thing. Only kept the logging and argparse really.