Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

45 Commits

Folders and files

Repository files navigation

Outlook Email to PDF Exporter

A comprehensive .NET application for exporting Microsoft Outlook items (emails, meetings, appointments, tasks, and more) to PDF format. Features advanced folder analysis, multi-threading support, session resumption, and comprehensive error handling.

Features

Core Functionality

  • Multi-format Export: Convert Outlook items to PDF, MSG, TXT, or HTML formats
  • Intelligent Item Processing: Supports emails, meetings, appointments, tasks, contacts, and sharing items
  • Folder Analysis: Analyze folder contents with item type breakdown and file existence checking
  • Selective Processing: Choose specific item types and folders to process
  • Duplicate Detection: Skip files that already exist with smart multi-extension checking

Performance & Reliability

  • Multi-threading Support: Parallel processing with COM-safe threading (configurable 1-3 threads)
  • Speed Optimization: 4 processing modes (SPEED, FAST, STANDARD, CONFIG) with different quality/speed tradeoffs
  • Session Resume: Automatic session persistence and recovery for interrupted processing
  • Comprehensive Logging: Detailed success/failure reporting with enhanced summary logs

Advanced Features

  • Attachment Handling: Automatic download and organization of email attachments
  • File Naming: Intelligent filename generation with sanitization and uniqueness handling
  • Error Recovery: Robust COM object cleanup and error handling for Outlook interop
  • Debug Support: Enhanced debugging for problematic items (especially SharingItems)

System Requirements

Prerequisites

  • Windows OS (required for Office COM interop)
  • .NET Framework 4.7.2 or higher
  • Microsoft Outlook (installed and configured)
  • Microsoft Word (required for PDF generation via COM Interop)

Runtime Dependencies

  • Outlook must be installed and have at least one configured email account
  • Word must be available for PDF conversion (application uses Word's SaveAs functionality)
  • Sufficient disk space for exported files and attachments

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd EmailToPdfExporter
  2. Build the solution:

    # Using MSBuild
    msbuild EmailToPdfExporter.sln /p:Configuration=Release
    
    # Or open in Visual Studio and build (Build → Build Solution)
  3. Run the application:

    cd EmailToPdfExporter/bin/Release
    ./EmailToPdfExporter.exe

Usage

Basic Operation

  1. Choose Processing Speed:

    • SPEED: Maximum speed (skip embedded images, shared Word app)
    • FAST: Optimized processing with embedded images (default)
    • STANDARD: Full quality, slower processing
    • CONFIG: Custom user configuration
  2. Select File Handling:

    • SKIP: Skip files that already exist (recommended)
    • OVERWRITE: Overwrite existing files
    • PROMPT: Ask for each file individually
  3. Choose Folders: Select from available Outlook folders or use shortcuts:

    • all: Process all folders
    • common: Inbox, Sent Items, and Archive
    • withitems: Only folders containing items
    • Specific numbers: 1,2,5 for selected folders
  4. Select Item Types: Choose which types to process:

    • all: All item types
    • emails: Email items only
    • meetings: Meeting items only
    • Specific numbers for custom selection

Output Structure

C:\Users\[Username]\Downloads\AI emails\
├── [FolderName]\
│   ├── 2023.12.15_143020_John_Doe_Project_Update.pdf
│   ├── 2023.12.15_143020_John_Doe_Project_Update_attachment1.xlsx
│   ├── 2023.12.16_090000_Meeting_Jane_Smith_Weekly_Review.pdf
│   └── ...
└── Reports\
    └── Processing_Summary_20231215_143020.txt

Architecture

Design Pattern

The application uses manual dependency injection with a service-oriented architecture. All components are abstracted behind interfaces and wired together in Program.cs.

Processing Pipeline

Program.cs (Entry + DI Container)
    ↓
EnhancedOutlookService (Primary orchestrator)
    ↓
Multi-step pipeline:
1. FolderSelector → User selects Outlook folders
2. FolderAnalyzer → Analyzes folder contents and types  
3. ItemTypeSelector → User chooses item types to process
4. FileExistenceChecker → Avoids duplicate processing
5. ItemProcessor → Strategy pattern for different item types
6. EmailExporter → Converts to PDF via Word COM
7. ResumeManager → Persists session for recovery
8. SummaryLogger → Comprehensive reporting

Key Components

  • Service Layer: IOutlookService implementations (Enhanced, Basic, Optimized)
  • Processing Strategy: IItemProcessor with item-specific processors
  • Session Management: IResumeManager for persistence and recovery
  • File Operations: IFileExistenceChecker and IFileNameGenerator
  • Analysis: IFolderAnalyzer and IItemInspector for content analysis

Configuration

Speed Settings

Each processing mode optimizes different aspects:

Mode Image Processing Word App Batch Processing Quality
SPEED Skip embedded Shared instance Yes Lower
FAST Include embedded Optimized Yes Good
STANDARD Full processing New instances No Highest
CONFIG User defined User defined User defined Variable

File Extensions

The application can create multiple file formats:

  • .pdf - Primary format via Word conversion
  • .msg - Native Outlook format (when supported)
  • .txt - Text summary (for unsupported items)
  • .html - HTML format (alternative export)

Troubleshooting

Common Issues

"COM object has been separated from its RCW"

  • Solution: Restart Outlook and the application
  • Cause: COM object cleanup issues

"Word application not available"

  • Ensure Microsoft Word is installed and licensed
  • Close any open Word documents before processing

"Access denied" errors

  • Run as Administrator if processing system folders
  • Check antivirus software blocking file access

Items show as "new" but aren't processed

  • Fixed in recent versions with consistent file existence checking
  • Ensure output directory is accessible

Debug Information

For problematic items (especially SharingItems), the application generates detailed debug information including:

  • All available COM properties
  • Key identification fields (EntryID, MessageClass)
  • Manual location tips for finding items in Outlook

Development

Building from Source

# Restore NuGet packages
nuget restore EmailToPdfExporter.sln

# Build solution
msbuild EmailToPdfExporter.sln /p:Configuration=Debug

Key Dependencies

  • Microsoft.Office.Interop.Outlook
  • Microsoft.Office.Interop.Word
  • System.Runtime.InteropServices (COM support)

Adding New Item Processors

  1. Implement IItemProcessor interface
  2. Add to processor collection in service classes
  3. Update ItemInspector for new item type detection

License

[Add your license information here]

Contributing

[Add contribution guidelines here]

Support

For issues and questions:

  1. Check the troubleshooting section above
  2. Review the generated summary reports for detailed error information
  3. Enable debug mode for additional logging
  4. [Add contact/issue reporting information]

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages