from pathlib import Path
import win32com.client
# Creation du repertoire
output_dir = Path.cwd() / "Backup"
output_dir.mkdir(parents=True, exist_ok=True)
# Acceder à outlook
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
# Recuperer la boite de reception
inbox = outlook.GetDefaultFolder(6)
# lien du chemin
pst = str(output_dir / "backup.pst")
# Export inbox folder to PST file
inbox.Export(pst)
I'm trying to export my inbox from Outlook as a pst file but I'm getting an error with the export method. Does anyone have an idea?
Call Namespace.AddStoreEx (where
Namespaceis youroutlookvariable), find the new Store object in the Namespace.Stores collection, then copy the Inbox folder to the new store (inbox.CopyTo(Store.GetRootFolder()))