Skip to content

πŸ“§ Cloud-synced email archiving for Outlook - Organize emails into year/month folders that sync across all devices. No more local PST files!

License

Notifications You must be signed in to change notification settings

Zeffer83/OutlookAutoArchive

Repository files navigation

Outlook Auto Archive

A professional PowerShell application that automatically archives emails older than a specified number of days from your Outlook Inbox to organized year/month folders. Features beautiful UI/UX with ASCII art banners and professional styling.

Author: Ryan Zeffiretti
Version: 2.9.5
License: MIT

πŸ€” Why Outlook Auto Archive?

The Problem with Built-in Outlook Archiving

Outlook's built-in archiving feature creates local .pst files that are stored on your computer's hard drive. While this works for a single machine, it creates several critical limitations:

πŸ”’ Single Computer Access

Archived emails are only available on the computer where they were archived. You can't access your archives from other computers with Outlook.

πŸ’Ύ Local Storage Dependency

Because the archive is just another local Outlook data file, a hard-drive failure or profile corruption can render it inaccessible or lostβ€”unless you've implemented a backup strategy for your PST files.

πŸ”„ No Cross-Device Sync

Local PST archives aren't part of Exchange or Microsoft 365 mailboxes. You can't open them from Outlook on a different PC or via Outlook on the webβ€”only from the Outlook profile where they're attached.

πŸ“ Disorganized Structure

AutoArchive preserves whatever folder hierarchy you had in your mailbox, but it doesn't auto-generate year/month folders. All "archived" items go into the PST's existing folder tree (or the default Archive folder), not into a neat calendar-based folder structure.

The Solution

Outlook Auto Archive solves these problems by:

  • ☁️ Cloud-Based Archiving: Moves emails to your existing Outlook folders that sync across all your devices
  • πŸ“± Multi-Device Access: Access your archived emails from any computer with Outlook installed
  • πŸ“‚ Organized Structure: Creates clean year/month folder hierarchies (e.g., Archive\2025\2025-08)
  • πŸ”„ Automatic Sync: Leverages your existing Outlook sync to make archives available everywhere
  • ⚑ Lightweight: No additional storage or complex setup required
  • πŸ›‘οΈ Data Safety: Uses your existing cloud backup and sync infrastructure
  • 🧹 Clean Inbox: Automatically moves old emails out of your inbox to keep it organized and clutter-free

Alternatives to Consider

  • Exchange Online Archive: A server-side archive mailbox that syncs across devices (requires Microsoft 365)
  • Third-Party Tools: Solutions like Clean Email can auto-archive into structured folders or cloud storage
  • Manual PST Management: You can create separate PSTs per year/month yourself, but it's a manual process

Perfect For

  • 🏒 Business Users who need access to archived emails across multiple workstations
  • 🏠 Home Users with multiple computers who want consistent email access
  • πŸ“± Remote Workers who switch between office and home computers
  • πŸ’Ό Anyone who wants better organized email archives that sync automatically
  • πŸ›‘οΈ Data-Conscious Users who want to avoid local PST file risks

✨ Features

  • 🎨 Beautiful User Interface: Professional ASCII art banners and color-coded sections
  • πŸ“§ Automatic Email Archiving: Moves emails older than X days from Inbox to Archive folders
  • πŸ“ Organized Structure: Creates year/month folder hierarchy (e.g., Archive\2025\2025-08)
  • πŸ›‘οΈ Dry-Run Mode: Test the application safely without actually moving emails
  • πŸ“ Comprehensive Logging: Detailed logs of all operations with timestamps
  • πŸ‘₯ Multi-Account Support: Works with multiple Outlook accounts/stores
  • πŸ” Smart Folder Detection: Automatically finds Archive folders in various locations
  • πŸ”„ Duplicate Prevention: Handles duplicate emails intelligently
  • βš™οΈ Custom Skip Rules: Built-in logic to skip specific emails (e.g., monitoring alerts)
  • βœ… Outlook Status Check: Automatically verifies Outlook is running before execution
  • πŸ› οΈ Enhanced Error Handling: Improved logging and error recovery
  • ⏰ Windows Task Scheduler: Easy setup for automatic archiving
  • πŸ“± Gmail Support: Works with Gmail accounts using custom labels
  • πŸ’» Console Compatibility: ASCII-compatible display that works on all Windows systems
  • 🎨 Professional UI: Clean, readable interface with consistent styling across all terminals

πŸ›‘οΈ Safety Features

  • πŸ›‘οΈ Dry-Run Mode: Test without making changes
  • πŸ”„ Duplicate Prevention: Avoids moving duplicate emails
  • πŸ› οΈ Error Handling: Graceful handling of missing folders or permissions
  • πŸ“ Backup Logging: All operations are logged before execution
  • πŸ”’ Windows Security: Automatic unblocking of downloaded executables

πŸ“‹ Prerequisites

  • Windows 10/11 with PowerShell 5.1 or later
  • Microsoft Outlook (desktop app) installed and configured
  • Outlook COM Interop permissions

πŸ”’ Windows Security

Automatic Unblocking

The application automatically detects and attempts to unblock itself if Windows has blocked it due to being downloaded from the internet. This is a normal Windows security feature.

Manual Unblocking

If automatic unblocking fails, you can manually unblock the executable:

  1. Right-click on OutlookAutoArchive.exe
  2. Select "Properties"
  3. Check the "Unblock" checkbox at the bottom of the dialog
  4. Click "OK"
  5. Run the application again

This is a one-time process - once unblocked, the file will run normally on subsequent executions.

πŸ’» Console Compatibility

Universal Display Support

The application uses ASCII-compatible characters instead of Unicode emojis to ensure proper display across all Windows console environments:

  • βœ… Consistent Display: All text indicators use ASCII characters that display correctly everywhere
  • πŸ–₯️ Cross-Platform: Works on all Windows systems regardless of console encoding
  • 🎯 Professional Appearance: Clean, readable text indicators like [OK], [ERROR], [TIP]
  • ⚑ Better Performance: No Unicode rendering issues or display glitches

Text Indicators

The application uses these ASCII-compatible indicators:

  • [OK] - Success messages and confirmations
  • [ERROR] - Error messages and failures
  • [!] - Warning messages and important notes
  • [TIP] - Helpful tips and recommendations
  • [EMAIL] - Email-related operations
  • [FOLDER] - Folder operations
  • [SCHEDULE] - Scheduling information
  • [STATS] - Statistics and summaries

This ensures that all users see the same professional interface regardless of their Windows console configuration.

πŸš€ Installation

Quick Start (Recommended)

  1. Download OutlookAutoArchive.exe from the latest release
  2. Double-click the executable to start the first-run setup
  3. Follow the guided setup to configure your preferences
  4. Test in dry-run mode to verify everything works
  5. Set up automatic scheduling using the included setup executable

Installation Details

The application automatically installs to C:\Users\[YourUsername]\OutlookAutoArchive on first run:

  • βœ… User-specific installation (no admin permissions required)
  • βœ… Easy to find and manage
  • βœ… Works with all Windows user types
  • βœ… Automatic configuration file creation

Files Included

  • OutlookAutoArchive.exe - Main application (recommended for all users)
  • OutlookAutoArchive.ps1 - Main application script (included in source code packages)
  • setup_task_scheduler.exe - Task scheduler setup executable (easy to use)
  • setup_task_scheduler.ps1 - Task scheduler setup script (included in source code packages)
  • config.json - Configuration file (auto-created on first run)

🎯 Why Use Executables?

Benefits of using the .exe files:

  • βœ… No PowerShell execution policy issues
  • βœ… Double-click to run - no command line needed
  • βœ… Works with Windows Task Scheduler out of the box
  • βœ… Automatic Windows security unblocking
  • βœ… Professional appearance with proper metadata
  • βœ… Easy for non-technical users

βš™οΈ Configuration

The application uses a config.json file for configuration. Edit this file to customize behavior:

{
  "RetentionDays": 14,
  "DryRun": true,
  "LogPath": ".\\Logs",
  "GmailLabel": "OutlookArchive",
  "SkipRules": [
    {
      "Mailbox": "Your Mailbox Name",
      "Subjects": ["Subject Pattern 1", "Subject Pattern 2"]
    }
  ]
}

Configuration Options

  • RetentionDays: Number of days to keep emails in Inbox before archiving (default: 14)
  • DryRun: When true, shows what would be moved without actually moving emails (default: true)
  • LogPath: Directory where log files are stored (supports %USERPROFILE% variable)
  • GmailLabel: Custom Gmail label name for archive folder (default: "OutlookArchive")
  • SkipRules: Array of rules to skip specific emails by mailbox and subject patterns

🎯 How It Works

  1. πŸ”— Connects to Outlook: Uses COM Interop to access Outlook
  2. πŸ“ Finds Archive Folder: Searches for Archive folder in multiple locations:
    • Inbox\Archive
    • Root-level Archive
    • Custom Gmail labels (configured via GmailLabel)
  3. πŸ“‚ Creates Folder Structure: Automatically creates year/month folders
  4. πŸ“§ Scans Inbox: Processes all emails in the Inbox
  5. πŸ“¦ Moves Old Emails: Moves emails older than retention period to appropriate archive folder
  6. πŸ“ Logs Everything: Records all operations to timestamped log files

πŸ“ Archive Structure

The application creates an organized folder structure:

Archive/
β”œβ”€β”€ 2025/
β”‚   β”œβ”€β”€ 2025-08/
β”‚   β”œβ”€β”€ 2025-07/
β”‚   └── ...
β”œβ”€β”€ 2024/
β”‚   β”œβ”€β”€ 2024-12/
β”‚   └── ...

πŸš€ Usage

First Run Setup

  1. Double-click OutlookAutoArchive.exe
  2. Follow the guided setup to configure archive folders and scheduling
  3. Test in dry-run mode to verify everything works
  4. Review logs in the Logs folder
  5. Set up automatic scheduling using the provided options

Manual Execution

# Run the executable (uses config.json automatically)
.\OutlookAutoArchive.exe

Scheduled Execution

The first-run setup offers daily scheduled archiving:

πŸ’‘ Design Philosophy: I have simplified the scheduling to focus on reliability and system performance. Unlike continuous monitoring solutions that stay in memory, this approach runs once per day and then completely unloads, ensuring your system remains responsive and efficient.

πŸ“… Daily at Specific Time

  • Runs once per day at your chosen time (e.g., 2:00 AM)
  • Perfect for users who want predictable, scheduled archiving
  • Gracefully skips runs when Outlook is not available
  • Simple and reliable scheduling option
  • Memory efficient - application unloads after each run, keeping your system responsive
  • Reliable performance - no background processes consuming system resources

βš™οΈ Manual Setup

Use setup_task_scheduler.exe to set up scheduling later:

# Run as Administrator
.\setup_task_scheduler.exe

Alternative: Use Windows Task Scheduler directly:

  1. Open Task Scheduler (search in Start menu)
  2. Click Create Basic Task
  3. Name: Outlook Auto Archive
  4. Trigger: Daily at your preferred time
  5. Action: Start a program
  6. Program: C:\Users\YourUsername\OutlookAutoArchive\OutlookAutoArchive.exe
  7. Check Run with highest privileges

πŸ“ Logging

Logs are stored in: Logs\ folder within your installation directory

Each run creates a timestamped log file: ArchiveLog_YYYY-MM-DD_HH-mm-ss.txt

Log entries include:

  • Configuration settings
  • Folder creation operations
  • Email movement details
  • Errors and warnings
  • Completion timestamp

🎨 Customization

Adding Skip Rules

To skip specific emails, add rules to the config.json file:

"SkipRules": [
    {
        "Mailbox": "Your Mailbox Name",
        "Subjects": [
            "Subject Pattern 1",
            "Subject Pattern 2"
        ]
    }
]

Gmail Setup

For Gmail accounts, the application uses custom labels instead of folders:

  1. Enable IMAP in Gmail settings
  2. Create a custom label (e.g., "OutlookArchive")
  3. Check "Show in IMAP" for the label
  4. Configure GmailLabel in your config.json

πŸ› οΈ Troubleshooting

Common Issues

  1. "Access Denied" errors: Ensure Outlook is running and you have permissions
  2. No Archive folder found: The application will help you create one during setup
  3. Executable won't run:
    • Windows may block downloaded files - the app will attempt to unblock automatically
    • If automatic unblocking fails, right-click β†’ Properties β†’ Check "Unblock"
  4. Config file issues: The app will auto-create config.json if missing
  5. Scheduled task not running: Ensure Outlook is running when the task executes

Debug Mode

Check the log files in the Logs folder for detailed error messages and operation history.

πŸ“„ License

This project is open source and available under the MIT License "AS IS".

Author: Ryan Zeffiretti

⚠️ Important Disclaimers

πŸ”’ Data Safety Warning

ALWAYS BACKUP YOUR DATA BEFORE USE! While this application includes safety features like dry-run mode and comprehensive logging, it's your responsibility to ensure you have proper backups of your email data before using this tool.

πŸ›‘οΈ No Warranty

This software is provided "AS IS" without warranty of any kind. The author makes no representations or warranties about the accuracy, reliability, completeness, or suitability of this software for any purpose.

πŸ“‹ User Responsibility

By using this software, you acknowledge that:

  • You have backed up your email data before use
  • You understand the risks involved in email operations
  • You accept full responsibility for any consequences
  • You will test the software in dry-run mode first

πŸ†˜ Support

If you encounter issues:

  1. Check the log files for detailed error messages
  2. Ensure Outlook is properly configured
  3. Verify you have necessary permissions
  4. Test with dry-run mode enabled
  5. Review the troubleshooting section above

Note: This application is designed for personal use and should be tested thoroughly in your environment before production use. Version 2.9.5 includes enhanced UI/UX with beautiful styling, professional interface design, and improved console compatibility.