1
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?

1
  • What error are you getting on export? Commented Jul 15, 2023 at 19:15

1 Answer 1

0

Call Namespace.AddStoreEx (where Namespace is your outlook variable), find the new Store object in the Namespace.Stores collection, then copy the Inbox folder to the new store (inbox.CopyTo(Store.GetRootFolder()))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.