Code Monkey home page Code Monkey logo

purduevin / outlookexport Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 11 KB

This Python script uses `pywin32` to export emails and attachments from Outlook into organized directories on your computer. It saves emails by received time and includes subject, body, and attachments, ideal for email backup and archiving.

License: MIT License

Python 100.00%
attachments automation backup data-archiving email email-exporter outlook python pywin32 windows

outlookexport's Introduction

This script facilitates the automated export of emails and attachments from Microsoft Outlook into a structured directory system on your Windows computer, leveraging the pywin32 library.

Script Description

This Python script automates the process of exporting emails and attachments from Microsoft Outlook into organized directories on your Windows system. It utilizes the pywin32 library to interact with Outlook, managing emails efficiently by sorting, saving, and organizing them into directories named after their received timestamps. Non-mail items are handled appropriately, and errors are robustly managed.

Key Features and Workflow:

  1. Modules Used:

    • datetime for handling date and time.
    • pathlib for file system path operations.
    • re for sanitizing filenames using regular expressions.
    • win32com.client for interacting with COM objects, specifically Microsoft Outlook.
  2. Utility Functions:

    • create_directory(base_path, folder_name): Manages directory creation.
    • save_attachments(attachments, folder_path): Saves email attachments to specified directories after cleaning filenames.
  3. Email Processing:

    • Accesses items in specified Outlook folders, sorting emails by "ReceivedTime".
    • Processes each email, creating directories named by email timestamp, saving subject and body to text files, and saving attachments.
  4. Execution and Error Handling:

    • Script initializes Outlook application access, processes all folders within each email account, and logs any errors or skips.
  5. Output:

    • Organizes emails in directories based on timestamps, includes both text files for email content and original formats for attachments.

System Requirements and Installation Guide:

  • Operating System Requirement: Designed specifically for Windows OS due to the dependence on pywin32 and Outlook.

  • Python Installation:

    1. Download Python:
    2. Install Python:
      • Run the downloaded installer.
      • Make sure to check "Add Python 3.x to PATH" at the bottom of the installation window to automatically add Python to your environment variables.
      • Click "Install Now".
  • Adding Python and pip to PATH Manually: If you didn’t add Python to your PATH during the installation, you can add it manually:

    1. Open the Start Search, type env, and select "Edit the system environment variables" or "Edit environment variables for your account".
    2. Under System Properties, click on the "Environment Variables…" button.
    3. Find the 'Path' variable in the "System variables" section and click "Edit…".
    4. Add Python path:
      • Click "New" and add the path to the folder where Python is installed, e.g., C:\Users\<Username>\AppData\Local\Programs\Python\Python39.
      • Add another new line for the Scripts directory, e.g., C:\Users\<Username>\AppData\Local\Programs\Python\Python39\Scripts.
    5. Click OK on all dialogs to close them.
  • Install pywin32:

    pip install pywin32
  • Running the Script:

    • Ensure Microsoft Outlook is installed and configured with your email account.
    • Run the script with administrative privileges to enable necessary permissions for accessing Outlook and performing file operations.

This setup ensures that the script can be run efficiently on any compatible Windows machine, providing a robust tool for exporting and archiving email data from Microsoft Outlook.

outlookexport's People

Contributors

purduevin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.