MailRaider Pro — Automation

MailRaider Pro is scriptable. It supports both AppleScript — for traditional Mac automation and integration with other scriptable applications — and Shortcuts on macOS 13 and later, for building visual automation workflows that can run from the Shortcuts app, the menu bar, Spotlight, or on a schedule.

Both interfaces expose the same underlying capabilities: opening and searching email archives (PST, OLK, MBOX, EML, MSG), extracting content and metadata, and exporting results. AppleScript is better suited to complex data processing and integration with other applications. Shortcuts is better suited to single-action or simple chained workflows that non-developers will run regularly.

AppleScript

The example scripts below cover the main scripting scenarios. Each is a standalone .applescript file with detailed inline comments. Download the ones relevant to your use case, open them in Script Editor, adjust the file paths in the configuration section at the top, and run.

All data-extraction operations work without opening MailRaider’s user interface. You can process hundreds of emails per minute in “data mode” with no windows appearing on screen.

01 — Opening and Processing a Single Email

How to open an email file in MailRaider’s UI, and how to extract data (subject, sender, date, recipients, body, attachments, headers) without opening any window. Includes examples that send email content to TextEdit and open HTML bodies in a browser.

Key commands demonstrated: open email reference file, process email file … returning, get content streams from reference, get email from reference

Download script 01

02 — Basic Email Properties

Focused examples for extracting individual properties: subject, sender, date, recipients, body text, email headers, and attachments. Includes a worked example that assembles a formatted summary from all fields in a single call using the full return type.

Key commands demonstrated: process email file … returning "full", property access on the returned record

Use returning "full" when you need multiple fields — it is faster than making individual calls for each property.

Download script 02

03 — Working with Content Streams

Emails can carry their body in multiple formats (plain text, HTML, RTF). This script shows how to detect which formats are available, retrieve a specific one, save HTML to a file for browser preview, and fall back gracefully when a format is absent. Also covers simple HTML-to-plain-text conversion for use with natural language processing tools.

Key commands demonstrated: get content streams from reference, get content stream of type … from reference

RTF is typically only present in MSG files. Plain text is always available. Prefer HTML for display, plain text for analysis.

Download script 03

04 — Searching Email Archives

How to search a folder of email files or a PST mailbox by sender, recipient, subject, body content, and date range. Includes examples combining multiple criteria, recursive subfolder scanning, and a recent-emails shortcut that calculates the date range automatically.

Key commands demonstrated: search folder in folder … searching … for …, search mailbox in file … searching … for …, from date … to date, recursive true

PST searches use a built-in index and are fast even on large archives. Body searches on folders of individual files are slower as they require loading each email’s content.

Download script 04

05 — Batch Processing and Iteration

Efficient processing of large numbers of emails. Covers basic iteration over search results, CSV export of email metadata, selective processing (e.g. only emails with attachments), building summary reports with sender statistics and date ranges, and memory-efficient batch processing in chunks of 100.

Key commands demonstrated: process email emailRef returning, get email from reference, result iteration with repeat with … in and repeat with i from 1 to

For large batches, use process email … returning (data mode) rather than open email reference (UI mode). Data mode has no UI overhead and is suitable for processing thousands of emails.

Download script 05

06 — Error Handling and Advanced Workflows

Best-practice error handling for MailRaider scripts: per-email try/catch in batch loops so a single corrupt file does not abort the entire run, error logging to disk, and structured error recovery. Also includes a multi-application workflow example combining MailRaider with TextEdit and the Finder.

Patterns demonstrated: error log accumulation, graceful skip on failure, file-handle cleanup in error handlers, progress reporting

Download script 06

MailRaider Example (simple starter)

A short, self-contained starter script. If you have not used MailRaider’s AppleScript support before, start here. Opens a single email, extracts its subject and sender, and displays a dialog. No helper functions, no complexity.

Download starter script

To explore MailRaider Pro’s full AppleScript dictionary, open Script Editor, choose File > Open Dictionary…, and select MailRaider Pro. The dictionary describes every command, class, and property.

Shortcuts — Available Actions

On macOS 13 and later, MailRaider Pro adds the following actions to the Shortcuts app. Actions can be combined in any sequence and chained with built-in Shortcuts actions (loops, conditions, text processing, file operations, etc.).

To find MailRaider Pro’s actions in Shortcuts, open the Shortcuts app, create a new shortcut, and search for “MailRaider” in the action library on the right.

Email Reference from File

Creates an email reference from a file you select in Finder (or supply from a “Get File” action). This is the entry point for workflows that start from a specific file rather than a search result. The reference can be passed to any of the content, open, or export actions below.

Input: a file path or Finder file. Output: an Email Reference.

Search Mailbox

Searches inside a PST, OLK, or MBOX archive file. Returns a list of Email References matching the criteria.

Output: list of Email References. Pass these to “Get Email Content”, “Get Content Stream”, “Open Email”, or “Export Emails”.

Search Folder

Searches a folder containing individual email files (MSG, EML, OFT, winmail.dat). Returns a list of Email References matching the criteria.

Output: list of Email References.

Get Email Content

Retrieves the full content of an email as a structured record: subject, sender, recipients, date, plain-text body, HTML body, email headers, and attachment names. Use this when you need several fields at once.

Input: an Email Reference (from Search Mailbox, Search Folder, or Email Reference from File). Output: an Email Content record with named fields.

List Content Types

Returns the list of body formats available in an email (e.g. “text”, “html”, “rtf”). Use before “Get Content Stream” when you are not certain which formats a particular email carries.

Input: an Email Reference. Output: a list of format name strings.

Get Content Stream

Retrieves a specific body format from an email as a text string.

Output: the body content as text. Can be passed directly to “Save File”, “Share”, a text action, or any other Shortcuts action that accepts text.

Export Emails

Saves one or more emails to individual files on disk.

Output: a list of paths to the exported files.

Open Email

Opens an email in MailRaider Pro’s UI for reading. Use this at the end of a search-and-select workflow when you want to view the email rather than process it programmatically. This action requires MailRaider Pro to be running and brings it to the foreground.

Input: an Email Reference. Output: none (side effect: email displayed in MailRaider Pro).

Shortcuts — Example Workflows

The examples below describe complete Shortcuts you can build by chaining the actions above. Each is described in terms of the actions involved and what they do, in sequence.

Find and open an email by subject

Good for: quickly locating a specific email in a large archive from anywhere on your Mac.

  1. Ask for Input (built-in) — prompt for a search term
  2. Search Mailbox — field: Subject, term: the input above
  3. Choose from List (built-in) — show the results, let you pick one
  4. Open Email — open the chosen result in MailRaider Pro

Add this shortcut to the menu bar for one-click archive search from anywhere.

Extract HTML from a file and save it

Good for: archiving a formatted email as a standalone HTML file, or feeding it to another tool.

  1. Get File (built-in) — select an MSG or EML file in Finder
  2. Email Reference from File — create a reference to it
  3. List Content Types — check what formats are available
  4. If (built-in) — check that the list contains “html”
  5. Get Content Stream — type: HTML
  6. Save File (built-in) — save the HTML text to a file

Export all emails from a sender to EML

Good for: pulling every email from a specific contact out of an archive for handover or review.

  1. Ask for Input (built-in) — prompt for a sender email address
  2. Search Mailbox — field: Sender, term: the input above
  3. Export Emails — format: EML, naming: Sender-Subject-Date, output folder: a folder on your Desktop
  4. Show Result (built-in) — display the number of files exported

PST to MBOX migration workflow

Good for: moving from Outlook to Apple Mail. Run this once; import the resulting MBOX into Apple Mail using File > Import Mailboxes.

  1. Get File (built-in) — select your PST file
  2. Search Mailbox — field: Sender, term: (leave blank to match everything)
  3. Export Emails — format: EML, naming: Sequential, output folder: a dedicated migration folder

For a folder-preserving MBOX export that retains your PST’s folder hierarchy, use the bulk export feature within MailRaider Pro’s UI directly (File > Bulk Export). The Shortcuts action exports individual EML files; the in-app export produces a proper nested MBOX.

Daily digest: emails received today

Good for: a scheduled shortcut that summarises recent email in an archive.

  1. Date (built-in) — get today’s date
  2. Format Date (built-in) — format as YYYY-MM-DD
  3. Search Mailbox — field: Date, from date: today, to date: today
  4. Repeat with each (built-in) — loop over results
  5. Get Email Content — for the current item
  6. Append to Note or Add to Log (built-in) — record subject and sender

Schedule this from the Shortcuts app using the “Run Shortcut” automation trigger.

Requirements

AppleScript: MailRaider Pro, any version. No additional configuration required. The application must be running when scripts execute, or scripts must include an explicit tell application “MailRaider Pro” block (which will launch the application automatically).

Shortcuts: MailRaider Pro 5 or later, macOS 13 (Ventura) or later. MailRaider Pro’s actions appear in the Shortcuts app automatically after installation. No additional configuration is required. Actions that do not open the UI (Search Mailbox, Search Folder, Get Email Content, Get Content Stream, Export Emails) can run in the background without MailRaider Pro being the frontmost app.

Both interfaces operate within macOS’s standard sandbox permissions. The first time a script or shortcut accesses a file or folder you have not previously approved, macOS will ask for your permission. Grant it once and it will be remembered.