Thanks, but I want to import old emails into the archiver.
Importing via outlook will import into gromox, but not into the archiver.
Nevermind, I found the solution.
The readpst binary comes with libpst and can be installed via zypper.
Nevertheless, it's pretty outdated and gave me a lot of segfaults. Since it was designed at outlook 2003 times, that might be normal.
So I ended up using libratom to do the pst to eml job, on another machine since installing libratom requires a c compiler and python >=3.7.
Here's my quick and dirty extractor code:
import os
from libratom.lib.pff import PffArchive
from email import generator
from pathlib import Path
def extract_eml(pstfile: str):
archive = PffArchive(pstfile)
output_dir = Path(Path.cwd() / pstfile[:-4])
if not output_dir.exists():
output_dir.mkdir()
errorcount = 0
print("Writing messages from {} to {}.eml".format(archive, output_dir))
if not archive.folders():
print("Archive {} has no folders".format(pstfile))
return False
for folder in archive.folders():
if folder and folder.get_number_of_sub_messages() != 0:
print("Folder {} has {} messages".format(folder.name, folder.get_number_of_sub_messages()))
for message in folder.sub_messages:
try:
if message.subject:
name = message.subject.replace(" ", "_")
name = name.replace("/","-")
else:
name = "nosubject"
except OSError:
print("Cannot get subject from message")
print(message)
exit()
try:
filename = output_dir / f"{message.identifier}_{name}.eml"
filename.write_text(archive.format_message(message))
except OSError:
print("Cannot save message {}".format(name))
errorcount += 1
else:
print("Empty folder")
if errorcount == 0:
print("Finished !")
else:
print("Finished with {} errors".format(errorcount))
if __name__ == "__main__":
for root, dirs, files in os.walk("./"):
for file in files:
if file.endswith(".pst") or file.endswith(".ost"):
extract_eml(file)
Hope this might help someone some day 😉