⚠️ Development stopped — This project is under active development. There is currently no installation package or release available. The only way to run the add-in is by building from source (see Building from Source).
Convert Outlook mail messages to PDF files with ease. SaveAsPDF is a Microsoft Outlook COM add-in that enables users to save emails and their attachments as PDF documents, with full support for project management, employee tracking, and advanced customization options.
- 📧 Email to PDF Conversion: Convert any Outlook email message to a professional PDF file
- 📎 Attachment Management: Select and save email attachments alongside the PDF
- 🏢 Project Management: Organize emails by project with automatic project ID detection from email subjects
- 👥 Employee Directory: Manage project team members with contact information and role assignment
- 📝 Rich Notes: Add and maintain both mail-specific and project-specific notes
- 🌳 Folder Structure: Browse and manage save locations with a Windows Explorer-style breadcrumb address bar and folder tree view
- 🎨 Customization: Configure fonts, colors, and application settings to your preference
- 🌍 Right-to-Left Support: Full support for Hebrew and other RTL languages
- 🌙 Dark Mode Support: Automatic theme adaptation to Windows system colors (light/dark modes)
- ⌨️ Quick Access: Ribbon interface for quick conversion of selected messages
- 🔒 Built-in Security: Input validation, path sanitization, HTML encoding, and safe file naming throughout
Security is built into the core of SaveAsPDF rather than added as an afterthought. The following protections are implemented and active:
- Project ID validation (
SafeProjectID): All project IDs are validated against a strict regex pattern before being used in any file system operation. Invalid IDs are rejected at the UI and helper layers. - Folder name sanitization (
SafeFolderName): Every folder and file name derived from user input or email data is scrubbed of all characters that are invalid on Windows file systems. Windows reserved device names (CON,PRN,AUX,NUL,COM1–COM3,LPT1–LPT3) are automatically renamed to avoid collisions. - Path normalization: All paths are resolved to their canonical form using
Path.GetFullPathbefore use, preventing path traversal attacks via relative path components (e.g...).
- HTML encoding: Every piece of user-supplied or email-derived data written into generated HTML (project name, project ID, notes, user name, employee names, email addresses, attachment names) is HTML-encoded with
WebUtility.HtmlEncodebefore insertion, preventing cross-site scripting (XSS) in Outlook's HTML renderer. - URI encoding: File paths embedded as
file:///links in generated HTML have special URI characters (space,#,?,%) percent-encoded, preventing link injection while correctly preserving non-ASCII (Hebrew/Arabic) characters.
- Unique file name generation: If a target file or folder already exists, a numbered suffix is appended automatically, preventing silent overwrites.
- Safe attachment saving: Attachment file names are sanitized by stripping all invalid file-system characters before being written to disk.
- Password-protected document detection: Word documents that are password-protected are detected before conversion is attempted, avoiding hangs or errors.
- Hidden configuration directories: The
.SaveAsPDFmetadata folder is created as a hidden directory, reducing accidental user modification or deletion of project data. - File attribute handling: Read-only or hidden attributes on existing XML configuration files are cleared before overwriting, preventing silent write failures.
UnauthorizedAccessExceptionhandling: File and directory operations explicitly catch access-denied errors and surface them to the user without crashing the add-in.- COM object lifecycle management: All Outlook COM objects (folders, items, stores) are released in
finallyblocks usingMarshal.ReleaseComObject, preventing use-after-free and memory leaks. - Diagnostic logging: Startup and selection-change exceptions are logged to
C:\Temp\SaveAsPDF_error.txtfor post-mortem debugging without exposing sensitive data in the UI. - MAPI filter injection prevention: Contact search queries escape single-quotes before being embedded in MAPI restriction filter strings, preventing filter injection.
- All user data (project metadata, employee lists, settings) is stored locally on the user's machine in XML files. No data is transmitted to remote servers.
- XML serialization uses
XmlReader/XmlWriterwith explicitUTF-8encoding, preventing encoding-related deserialization issues.
- Microsoft Outlook: 2016 or later (Office 365 / Microsoft 365 compatible)
- .NET Framework: 4.7.2 or higher
- Windows: Windows 7 or later (32-bit or 64-bit)
- RAM: Minimum 512 MB (1 GB or more recommended)
⚠️ No installer is available yet. This project is a work in progress. You must build the add-in from source and register it manually (see below).
-
Clone the repository:
git clone https://github.com/ofer-aha/SaveAsPDF.git cd SaveAsPDF -
Open
SaveAsPDF.slnin Visual Studio 2019 or later. -
Restore NuGet packages:
nuget restore SaveAsPDF.sln
-
Build the solution (Release configuration recommended):
msbuild SaveAsPDF.sln /p:Configuration=Release
-
Register the COM add-in (run as Administrator):
regasm /codebase SaveAsPDF\bin\Release\SaveAsPDF.dll
This registers the add-in under
HKCU\Software\Microsoft\Office\Outlook\Addins\SaveAsPDF.ConnectwithLoadBehavior=3(load at Outlook startup). -
Restart Microsoft Outlook — the SaveAsPDF ribbon button will appear.
dotnet test SaveAsPDF.Tests\SaveAsPDF.Tests.csproj- Select an Email: Click on the email you want to convert in Outlook.
- Click "Save as PDF": Use the SaveAsPDF button in the Outlook ribbon to open the task pane.
- Configure Options:
- Enter or select a project number (auto-detected from the email subject when possible)
- Choose attachments to include
- Add notes or project-specific information
- Select the save location using the breadcrumb address bar or folder tree
- Save: Click the "Save as PDF" button to generate the file.
-
Create a New Project: Click "New Project" in the task pane.
- Set project number, name, and default save location.
- Add team member information.
-
Add Employees: Access the Employees tab to manage team member details and assign the project leader role.
-
View Project Notes: Switch between mail notes and project notes using the sub-tabs.
Email subjects with project IDs are automatically recognised. For example:
- Subject:
Project 1234 - Meeting Notes→ detected project ID:1234 - Supported formats: 3–4 digit IDs with optional letter suffix and up to two hyphenated sub-segments (e.g.
1234,1234A,1234-1,1234-1-2)
SaveAsPDF/
├── SaveAsPDF/ # Main add-in project (COM add-in, no VSTO runtime)
│ ├── GUI_Logic/ # Task pane business logic
│ │ └── MainFormTaskPaneControl.cs
│ ├── GUI/ # Task pane layout (designer-generated)
│ │ └── MainFormTaskPaneControl.GUI.cs
│ ├── Helpers/ # Helper classes
│ │ ├── FileFoldersHelper.cs # Path sanitization, safe folder/file names
│ │ ├── HtmlHelper.cs # HTML generation with XSS protection
│ │ ├── MailLogic.cs # Email sending utilities
│ │ ├── OfficeHelpers.cs # Word/Outlook COM interop, PDF conversion
│ │ ├── OutlookProcessor.cs # Outlook contact and folder enumeration
│ │ ├── PathBreadcrumbHelper.cs # Breadcrumb ↔ path conversion
│ │ ├── SettingsHelpers.cs # Application settings management
│ │ ├── TextHelpers.cs # Text processing utilities
│ │ ├── TreeHelpers.cs # Folder tree operations
│ │ ├── XmlFileHelper.cs # XML serialization/deserialization
│ │ └── DiagnosticsAndBehavior.cs # Logging and behavior helpers
│ ├── Models/ # Data models
│ │ ├── ProjectModel.cs
│ │ ├── EmployeeModel.cs
│ │ ├── SettingsModel.cs
│ │ ├── AttachmentsModel.cs
│ │ ├── DocumentModel.cs
│ │ └── ContactFolderInfo.cs
│ ├── Connect.cs # COM add-in entry point (IDTExtensibility2)
│ ├── AddinGlobals.cs # Global add-in state
│ ├── FormSettings.cs # Settings dialog
│ ├── FormContacts.cs # Employee management dialog
│ ├── FormNewProject.cs # New project creation dialog
│ ├── SettingsTaskPaneControl.cs # Settings task pane
│ └── WordConvert.cs # Word-to-PDF conversion
├── SaveAsPDF.Tests/ # Unit tests (MSTest)
├── BenchmarkSuite1/ # Performance benchmarks
└── README.md # This file
| Component | Technology |
|---|---|
| Language | C# 7.3 |
| Runtime | .NET Framework 4.7.2 |
| Add-in type | COM Add-in (IDTExtensibility2) — no VSTO runtime required |
| Office integration | Microsoft Office Interop (Outlook, Word) |
| UI | Windows Forms |
| Configuration | XML (project data, employee lists, settings) |
| JSON | Newtonsoft.Json 13.0.3 |
| Dialogs | Ookii.Dialogs.WinForms 4.0.0 |
| Testing | MSTest 2.2.10 |
Connect: COM add-in entry point implementingIDTExtensibility2,IRibbonExtensibility, andICustomTaskPaneConsumer. Handles Outlook lifecycle, task pane creation, and ribbon callbacks.MainFormTaskPaneControl: Outlook sidebar task pane with RTL layout, dark mode support, tabbed interface (Attachments, Employees, Folders, Notes), and all core user interactions.FileFoldersHelper:SafeProjectID(regex-validated project IDs),SafeFolderName(file-system character scrubbing + reserved-name protection), path normalization, and directory management.HtmlHelper: Generates HTML summary files with fullWebUtility.HtmlEncodeprotection on all user-supplied fields and safefile:///URI construction.OfficeHelpers: Drives Word-to-PDF conversion via Office Interop with safe attachment file name handling and full COM object lifecycle management.XmlFileHelper: XML serialization/deserialization forProjectModel,EmployeeModel, andSettingsModel, withUnauthorizedAccessExceptionhandling and file attribute management.OutlookProcessor: Outlook contact and folder enumeration with MAPI filter quote-escaping and full COM object release infinallyblocks.
SaveAsPDF stores project metadata in hidden files alongside the project folder:
| File | Contents |
|---|---|
.SaveAsPDF_Project.xml |
Project information (name, notes, metadata) |
.SaveAsPDF_Emploeeys.xml |
Team member list and roles |
App settings (Settings.Default) |
User preferences and configurations |
DefaultTree.fld |
Default folder structure template |
The .SaveAsPDF metadata folder is created as a hidden directory so it does not appear during normal project file browsing.
The Outlook sidebar provides:
- Top Section: Project ID and name, email subject, breadcrumb save-location selector
- Middle Section: Tabbed content — Attachments, Employees, Folders, Notes (with mail/project sub-tabs)
- Bottom Section: Action buttons (Save to PDF, Cancel, Settings, New Project), status messages, open-PDF checkbox
Save locations are displayed in Windows Explorer-style breadcrumb format (C › Projects › 1000) for readability. The control automatically converts between breadcrumb display and editable full paths on focus.
- Light Mode: Uses
SystemColors.WindowandSystemColors.Control - Dark Mode: Automatically adapts to the Windows system dark theme
- RTL Layout: Full right-to-left support for Hebrew and Arabic
- Visual Studio 2019 or later
- .NET Framework 4.7.2 Developer Pack
- Microsoft Office development tools (Outlook and Word interop assemblies)
- NuGet package manager
- PascalCase for class and method names; camelCase for local variables;
_prefix for private fields - XML documentation comments on all public members
- Verify the DLL is registered: check
HKCU\Software\Microsoft\Office\Outlook\Addins\SaveAsPDF.Connect - Check for disabled add-ins: File → Options → Add-ins → Manage COM Add-ins
- Review
C:\Temp\SaveAsPDF_error.txtfor startup errors - Restart Outlook after registration
- Large attachments: Some emails may take longer to process
- Encoding issues: Ensure the email is in standard format (not RTF only)
- Path issues: Verify write permissions to the selected save location
- UNC paths: Network paths may require authentication
- Special characters:
SafeFolderNameautomatically replaces invalid characters, but very long paths may still hit the Windows 260-character limit (enable long paths in Windows 10+)
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/YourFeature - Make your changes: Follow the existing code style
- Write tests: Add unit tests for new functionality
- Submit a Pull Request: Describe your changes and reference any issues
This project is licensed under the MIT License — see the LICENSE file for details.
- GitHub Issues: Report a bug
- Discussions: Start a discussion
See SaveAsPDF/CHANGELOG.md for version history and release notes.
SaveAsPDF is provided as-is. The developers are not responsible for data loss or corruption, PDF conversion quality or accuracy, compatibility issues with specific Outlook versions, or third-party software conflicts.
- Installation package / ClickOnce installer
- Cloud storage integration (OneDrive, SharePoint)
- Batch PDF conversion
- Email template customization
- Archive management and search
- Modern .NET 6+ migration
Status: Work in Progress — no release package available yet
Repository: github.com/ofer-aha/SaveAsPDF