# Outlook MSG to JSON: Parse .msg Email Files (`eliai/outlook-msg-to-json`) Actor

Parse Outlook .msg email files to JSON: sender, to, cc, bcc, subject, dates, text and HTML body (recovered from RTF), links, headers and attachments, incl. emails attached inside emails. Batch .msg file URLs. For e-discovery, support teams and AI agents. Failed files are never charged.

- **URL**: https://apify.com/eliai/outlook-msg-to-json.md
- **Developed by:** [Broke to Built](https://apify.com/eliai) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 message parseds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### Outlook MSG to JSON: Parse .msg Email Files

**Give links to Outlook `.msg` files. Get sender, recipients, subject, dates, plain-text and HTML body, links, headers and attachments as clean JSON, one row per file. Emails attached inside emails are parsed too.**

`.msg` is Outlook's binary format (an OLE container, not text), so most email parsers, LLMs and AI agents cannot read it. This Actor turns it into fields you can search, store or hand to a model.

| You give it | You get back | You pay (Free plan) |
|---|---|---|
| `.msg` file URLs, or one file as base64 | `from`, `to`, `cc`, `bcc`, `subject`, `sentAt`, `receivedAt`, `messageId`, `text`, `html`, `links`, `attachments`, nested messages, key headers | **$0.002 per message parsed** |

Files that are not Outlook messages, downloads that fail, and links to private or internal addresses are written to the dataset with the reason and are **never charged**.

#### Try it in one click

Press **Start** with the form empty. A built-in sample message is parsed **for free** so you can see the output:

```json
{}
```

```json
{
  "ok": true,
  "source": "sample.msg",
  "subject": "title",
  "to": [{ "name": "to@example.com", "address": "to@example.com" }],
  "cc": [{ "name": "cc@example.com", "address": "cc@example.com" }],
  "receivedAt": "2019-03-05T07:22:17.000Z",
  "text": "body",
  "bodySource": "plain",
  "attachmentCount": 0,
  "attachments": [],
  "sample": true
}
```

#### Parse your own files

```json
{
  "msgUrls": [
    "https://your-bucket.s3.amazonaws.com/exports/invoice-1042.msg",
    "https://your-bucket.s3.amazonaws.com/exports/re-contract.msg"
  ],
  "saveAttachments": true
}
```

### What it handles

- **HTML hidden in RTF.** Outlook often stores the HTML body only inside compressed RTF. It is decompressed and recovered, and `text` is filled from it when the message has no plain-text body.
- **Emails attached inside emails** (forwarded as attachment), up to 3 levels deep, each with its own sender, recipients, body and attachments. One file is one charge, however many messages are nested in it.
- **Attachments**: name, MIME type, size, inline flag and content ID. Turn on `saveAttachments` to get a download link for each file.
- **Voting buttons**, conversation topic, message class (`IPM.Note`, meeting requests and so on).
- **Non-English text** (Unicode subjects and bodies).

### Who this is for

- **AI agents and RAG pipelines** that receive `.msg` attachments and need the email as fields, not bytes.
- **Legal, compliance and e-discovery** teams working through exported Outlook mail.
- **Support and finance teams** turning saved emails into tickets, invoices or CRM records.

### Input

| Field | What it does |
|---|---|
| `msgUrls` | Public links to `.msg` files. Up to 500 per run. |
| `msgBase64` | One `.msg` file as base64, for callers that hold the file in memory. |
| `includeHtml` | Return the HTML body (default on). |
| `includeRtfText` | Also return the RTF body for rich-text (non-HTML) messages. |
| `saveAttachments` | Save top-level attachments to run storage and return download links. |
| `maxFileSizeMb` | Skip files larger than this (default 25, max 100). |

### Output fields

`ok`, `source`, `fileSizeBytes`, `messageClass`, `subject`, `from`, `to`, `cc`, `bcc`, `sentAt`, `receivedAt`, `createdAt`, `messageId`, `conversationTopic`, `text`, `html`, `bodySource` (`plain`, `html`, `rtf` or `none`), `links`, `votingOptions`, `attachmentCount`, `attachments[]`, `headers`. Failed rows have `ok: false` and `error`.

### Pricing

Pay per event: **$0.002 per `.msg` file parsed.** The free sample and every failed file cost nothing.

### Privacy and safety

Files are read in memory for the run and are not kept anywhere except your own run storage. Links that point to private networks, localhost or cloud metadata addresses are refused, on every redirect.

### Related

Have `.eml` files instead? Use our **EML to JSON** Actor.

# Actor input Schema

## `msgUrls` (type: `array`):

Public links to Outlook .msg files (for example from S3, Google Drive direct links or your own server). One JSON row per file. Leave empty to see a free sample result.

## `msgBase64` (type: `string`):

Paste the base64 content of a single .msg file instead of a link. Handy for agents and API callers that hold the file in memory.

## `includeHtml` (type: `boolean`):

Return the HTML body next to the plain text. When Outlook stored the HTML only inside compressed RTF, it is recovered from there.

## `includeRtfText` (type: `boolean`):

Also return the decompressed RTF body for messages written in rich text (not HTML).

## `saveAttachments` (type: `boolean`):

Store each attachment of the top-level message in the run's key-value store and add a download URL. Off by default: you still get name, type and size.

## `maxFileSizeMb` (type: `integer`):

Larger files are skipped, recorded and never charged.

## Actor input object example

```json
{
  "msgUrls": [],
  "includeHtml": true,
  "includeRtfText": false,
  "saveAttachments": false,
  "maxFileSizeMb": 25
}
```

# Actor output Schema

## `results` (type: `string`):

One row per .msg file. Export as JSON, CSV or Excel from the dataset view.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("eliai/outlook-msg-to-json").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("eliai/outlook-msg-to-json").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call eliai/outlook-msg-to-json --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eliai/outlook-msg-to-json"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ySSi7WtlEFekSO8WS/builds/Hcr3fNjefgnCANXKI/openapi.json
