This script extracts emails and attachments from a PST file. The emails are saved in individual folders with their body, metadata, and attachments. Additionally, all attachments are saved in a separate global directory.
- Python 3.x
- pypff
- filetype
-
Clone the repository:
git clone https://github.com/yourusername/pst-email-attachment-extractor.git cd pst-email-attachment-extractor
-
Install the required libraries:
pip install pypff filetype
-
Place your PST file in the project directory and rename it to
file.pst
or update thepst_file_path
variable in the script to match your file name. -
Run the script:
python extract_emails_and_attachments.py
-
The extracted emails and attachments will be saved in the
extracted_emails_and_attachments
directory.
The script performs the following tasks:
- Opens the PST file and retrieves the root folder.
- Processes each folder recursively to extract emails and their attachments.
- Saves each email in a directory named after the email's subject.
- Saves the email body in plain text, HTML, or RTF format.
- Saves the email metadata (subject, sender, recipients) in a text file.
- Saves attachments in both the email's directory and a global
all_attachments
directory.
This project is licensed under the MIT License.
Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.