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.
- 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
- 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
- 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)
- 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)
- 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
-
Clone the repository:
git clone <repository-url> cd EmailToPdfExporter
-
Build the solution:
# Using MSBuild msbuild EmailToPdfExporter.sln /p:Configuration=Release # Or open in Visual Studio and build (Build → Build Solution)
-
Run the application:
cd EmailToPdfExporter/bin/Release ./EmailToPdfExporter.exe
-
Choose Processing Speed:
SPEED: Maximum speed (skip embedded images, shared Word app)FAST: Optimized processing with embedded images (default)STANDARD: Full quality, slower processingCONFIG: Custom user configuration
-
Select File Handling:
SKIP: Skip files that already exist (recommended)OVERWRITE: Overwrite existing filesPROMPT: Ask for each file individually
-
Choose Folders: Select from available Outlook folders or use shortcuts:
all: Process all folderscommon: Inbox, Sent Items, and Archivewithitems: Only folders containing items- Specific numbers:
1,2,5for selected folders
-
Select Item Types: Choose which types to process:
all: All item typesemails: Email items onlymeetings: Meeting items only- Specific numbers for custom selection
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
The application uses manual dependency injection with a service-oriented architecture. All components are abstracted behind interfaces and wired together in Program.cs.
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
- Service Layer:
IOutlookServiceimplementations (Enhanced, Basic, Optimized) - Processing Strategy:
IItemProcessorwith item-specific processors - Session Management:
IResumeManagerfor persistence and recovery - File Operations:
IFileExistenceCheckerandIFileNameGenerator - Analysis:
IFolderAnalyzerandIItemInspectorfor content analysis
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 |
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)
"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
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
# Restore NuGet packages
nuget restore EmailToPdfExporter.sln
# Build solution
msbuild EmailToPdfExporter.sln /p:Configuration=Debug- Microsoft.Office.Interop.Outlook
- Microsoft.Office.Interop.Word
- System.Runtime.InteropServices (COM support)
- Implement
IItemProcessorinterface - Add to processor collection in service classes
- Update
ItemInspectorfor new item type detection
[Add your license information here]
[Add contribution guidelines here]
For issues and questions:
- Check the troubleshooting section above
- Review the generated summary reports for detailed error information
- Enable debug mode for additional logging
- [Add contact/issue reporting information]