A native C# console application that exports contacts and email recipients from Microsoft Outlook to CSV or JSON format. Part of the AfterShell post-exploitation toolkit.
✨ Standalone Executable: This application builds as a single-file executable with no DLL dependencies. Just copy the .exe and run it anywhere on Windows x64 systems.
1. Build the Application
cd C:\Dev\AfterShell\exfil\OutlookExporter
build-outlookexporter.bat2. Export Your First Data
# Export all contacts to CSV (default)
bin\Release\net8.0-windows\win-x64\publish\OutlookExporter.exe
# Output: outlook_contacts_YYYYMMDD_HHMMSS.csv in current directory| Task | Command |
|---|---|
| Export contacts to CSV | OutlookExporter.exe |
| Export to JSON | OutlookExporter.exe --json |
| Export to both formats | OutlookExporter.exe --csv --json |
| Display as matrix | OutlookExporter.exe --matrix |
| List contact folders | OutlookExporter.exe --list |
| Export recipients | OutlookExporter.exe --recipients --limit 100 |
| List accounts | OutlookExporter.exe --list-accounts |
- Contacts Export: Export all contacts from Outlook's contact folders
- Email Recipients Export: Extract unique email addresses from email messages (senders and recipients)
- Contact Frequency Tracking: Track how many times each contact was contacted and their latest contact date
- Smart Sorting: Results sorted by most frequently contacted (recipients mode)
- Multi-Account Support: Process all configured email accounts or specific ones
- Folder Selection: Choose specific contact or mail folders to process
- Limit Control: Process only a specific number of emails for faster extraction
- Exchange Support: Resolves Exchange/EX addresses to SMTP format
- JSON Export: Export data to JSON format
- Matrix Display: Display results as a formatted table in the terminal
- Simultaneous Output: Export to CSV, JSON, and display matrix all at once
- .NET 8.0 SDK or later (can be changed to .NET 6.0+ in the .csproj file)
- Microsoft Outlook installed on Windows
- Windows operating system
Note: This project is configured to build as a single-file standalone executable. See the Single-File Build Guide for details.
# Navigate to the project folder
cd exfil\OutlookExporter
# Publish as single-file executable (Debug)
dotnet publish -c Debug
# Publish as single-file executable (Release)
dotnet publish -c Release
# Output location:
# bin\Release\net8.0-windows\win-x64\publish\OutlookExporter.exe- Open the
OutlookExporter.csprojfile in Visual Studio - Build the solution (Ctrl+Shift+B)
- Run the application (F5)
# Navigate to the project folder
cd exfil\OutlookExporter
# Build both Debug and Release versions
build-outlookexporter.bat
# Build and run with arguments
build-and-run-outlookexporter.bat --help
build-and-run-outlookexporter.bat --recipients --limit 100After building, find your standalone executable at:
bin\Debug\net8.0-windows\win-x64\publish\OutlookExporter.exe (Debug build)
bin\Release\net8.0-windows\win-x64\publish\OutlookExporter.exe (Release build)
✨ No DLLs required! The executable includes all dependencies. Just copy and run anywhere on Windows x64.
Export all contacts to a default timestamped CSV file:
OutlookExporter.exeExport contacts to JSON format only:
OutlookExporter.exe --jsonExport to both CSV and JSON simultaneously:
OutlookExporter.exe --csv --jsonExport to CSV, JSON and display matrix (all at once):
OutlookExporter.exe --csv --json --matrixDisplay contacts as a matrix table in terminal only:
OutlookExporter.exe --matrixExport to CSV and also display matrix:
OutlookExporter.exe --csv --matrixExport contacts to a specific base filename (extensions added automatically):
OutlookExporter.exe --output my_contacts --csv --jsonExport contacts from a specific Outlook folder:
OutlookExporter.exe --folder "Contacts/Work Contacts"List all available contact folders in Outlook:
OutlookExporter.exe --listExport recipients from first 100 emails in Inbox (CSV by default):
OutlookExporter.exe --recipients --limit 100Export recipients to both CSV and JSON:
OutlookExporter.exe --recipients --limit 100 --csv --jsonExport to CSV, JSON and display matrix simultaneously:
OutlookExporter.exe --recipients --limit 100 --csv --json --matrixDisplay recipients as a matrix table in terminal only:
OutlookExporter.exe --recipients --limit 100 --matrixExport to JSON and also display matrix:
OutlookExporter.exe --recipients --limit 100 --json --matrixExport recipients from Sent Items folder:
OutlookExporter.exe --recipients --mailfolder "Sent Items" --limit 200Export recipients from all accounts in all formats:
OutlookExporter.exe --recipients --limit 100 --all-accounts --csv --json --matrixExport from Sent Items across all accounts:
OutlookExporter.exe --recipients --mailfolder "Sent Items" --limit 100 --all-accountsExport from specific account only:
OutlookExporter.exe --recipients --account "work@company.com" --limit 100List all configured email accounts:
OutlookExporter.exe --list-accounts| Option | Description |
|---|---|
-o, --output <file> |
Output file path (default: outlook_contacts_YYYYMMDD_HHMMSS.csv/json) |
-f, --folder <path> |
Specific contacts folder path (e.g., "Contacts/MyFolder") |
-l, --list |
List all available contact folders and exit |
| Option | Description |
|---|---|
-r, --recipients |
Export email recipients instead of contacts |
-m, --mailfolder <name> |
Mail folder to process (default: Inbox). Options: Inbox, "Sent Items", Outbox, Drafts |
--limit <n> |
Limit number of emails to process per folder |
-a, --account <email> |
Process specific email account only |
--all-accounts |
Process all configured email accounts |
--list-accounts |
List all configured email accounts and exit |
| Option | Description |
|---|---|
--csv |
Export to CSV format (default if no format specified) |
--json |
Export to JSON format |
--matrix |
Display results as a matrix table in terminal |
Note: All output format options can be used simultaneously. For example, --csv --json --matrix will export to both CSV and JSON files and display the matrix in the terminal.
| Option | Description |
|---|---|
-o, --output <file> |
Output file path |
-h, --help |
Show help message |
- Full Name, First Name, Last Name, Middle Name
- Email 1, Email 2, Email 3
- Company, Job Title, Department
- Business Phone, Home Phone, Mobile Phone, Business Fax
- Business Address, Home Address
- Birthday, Anniversary
- Notes, Categories
- Email - SMTP email address (Exchange addresses are resolved)
- Name - Display name
- Type - Sender, To (Recipient), CC (Recipient), or BCC (Recipient)
- Account - Which email account this came from
- ContactCount - Number of times this contact was contacted within the processed emails
- LatestContactDate - Most recent contact date/time with this email address
- IsOwnAccount - Indicates if the email address belongs to one of the configured Outlook accounts ("Yes" or empty)
Note: Recipients are sorted by ContactCount (most contacted first), then by LatestContactDate.
The --matrix option displays a subset of fields in a formatted table:
- Contacts Matrix: Name, Email, Company, Job Title, Mobile, Business Phone
- Recipients Matrix: Email, Name, Type, Account, Times Contacted, Latest Contact, Own (sorted by most contacted)
- Own accounts (emails configured in Outlook) are marked with
*and highlighted in cyan - A legend at the bottom shows the count of own accounts used for export
- Own accounts (emails configured in Outlook) are marked with
Extract all contacts and their email addresses:
OutlookExporter.exe --csv --jsonIdentify most frequently contacted addresses:
OutlookExporter.exe --recipients --limit 500 --all-accounts --matrixDisplay contacts in terminal without creating files:
OutlookExporter.exe --matrixExport everything from all accounts:
# Export contacts
OutlookExporter.exe --csv --json -o all_contacts
# Export recipients from Inbox
OutlookExporter.exe --recipients --all-accounts --limit 1000 --csv --json -o inbox_recipients
# Export recipients from Sent Items
OutlookExporter.exe --recipients --all-accounts --mailfolder "Sent Items" --limit 1000 --csv --json -o sent_recipientsFocus on a single email account:
OutlookExporter.exe --recipients --account "work@company.com" --limit 500 --csv --matrix- Uses Microsoft Outlook COM automation
- Proper COM object cleanup to prevent memory leaks
- Works whether Outlook is running or not
- Compatible with all Outlook versions that support COM
- Deduplicates email addresses (recipients mode)
- Aggregates contact frequency and latest contact date
- Resolves Exchange (EX) addresses to SMTP format
- Handles multiple email accounts in Outlook profile
- CSV: UTF-8 with BOM for Excel compatibility
- JSON: UTF-8 with proper escaping
- Matrix: Formatted terminal output with column sizing
- Progress indicators for long operations
- Efficient memory usage with COM object cleanup
- Limit controls for processing large mailboxes
- Sorted output for meaningful results
- The application works whether Outlook is open or closed
- COM objects are properly released to prevent memory leaks
- CSV files are encoded in UTF-8 with BOM for Excel compatibility
- JSON files are UTF-8 encoded with proper escaping
- Progress is shown during export
- Dates are formatted as YYYY-MM-DD (contacts) or YYYY-MM-DD HH:MM:SS (recipients)
- Email recipients are deduplicated and aggregated (each address appears only once with contact count)
- Recipients are sorted by contact frequency (most contacted first)
- Matrix display truncates long values and caps column widths for readability
- Output formats can be combined:
--csv --json --matrixoutputs all three simultaneously - When using multiple file formats, extensions are automatically appended (e.g.,
output.csvandoutput.json)
Solution:
- Ensure Microsoft Outlook is installed on your system
- Make sure you have proper permissions to access Outlook
- Try running as administrator if permission issues persist
Solution:
- Verify the folder path is correct using the
--listoption - Check that you have access to the specified folder
- Folder names are case-sensitive
Solution:
- Use
--list-accountsto see available accounts - Folder names may vary by language (e.g., "Sent Items" vs "Verzonden items")
- Verify the account email address is correct
Solution:
- Check if the contacts folder or mailbox has any items
- Verify folder permissions
- Try without specifying a folder to use defaults
Solution:
- This is expected for some Exchange environments
- The tool tries multiple methods to resolve EX to SMTP
- Exchange cached mode may affect resolution
- Exported data may contain sensitive personal information
- CSV/JSON files are not encrypted
- Consider secure deletion of exported files after use
- Be aware of data protection regulations (GDPR, etc.)
This utility is part of the AfterShell post-exploitation toolkit. It can be integrated with other AfterShell tools:
# Example: Combine with screen capture
OutlookExporter.exe --recipients --limit 100 -o contacts.csv
ScreenCapture.exe -c 5 -i 2 -o screens.zip
# ... additional exfil operationsThis tool is part of the AfterShell project. Contributions, bug reports, and feature requests are welcome at:
GitHub: https://github.com/Logisek/AfterShell
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Same as the parent project.
Copyright (C) 2025 Logisek
- Website: https://logisek.com
- Email: info@logisek.com
- Project: https://github.com/Logisek/AfterShell
- Initial release
- Contacts export to CSV/JSON
- Email recipients export with frequency tracking
- Multi-account support
- Exchange address resolution
- Matrix terminal display
- Simultaneous multiple output formats