---
title: "OFT vs MSG: Outlook templates and message files"
url: https://recursiveai.org/onemail/articles/oft-vs-msg/
description: "Inspect the template marker in C#, then read the subject and message fields from both file types with OneMail 1.0.1."
date: 2026-11-16
author: OneMail team
---

# OFT vs MSG: Outlook templates and message files

Inspect the template marker in C#, then read the subject and message fields from both file types with OneMail 1.0.1.

November 16, 2026 · OneMail team

**An OFT is an Outlook template for a new item; an MSG stores an Outlook item.** Both use the same file structure, so OneMail reads both through the same API.

OneMail is a free, open-source .NET library from Recursive AI for reading and writing Outlook MSG, OFT and EML files ([MIT or Apache-2.0](https://licenses.nuget.org/MIT%20OR%20Apache-2.0)). [NuGet](https://www.nuget.org/packages/RecursiveAI.OneMail/1.0.1) · [GitHub](https://github.com/recursive-ai-oss/onemail-csharp).

[Jump to the C# example](#csharp-example)

## Read MSG and OFT files in C# with OneMail

This complete example uses [RecursiveAI.OneMail 1.0.1](https://www.nuget.org/packages/RecursiveAI.OneMail/1.0.1). It creates two local files from the same set of message fields, writes one as a template, then opens both with `MsgFile.TryOpen`. No Outlook application or mailbox is involved. Start a .NET 10 console project:

*Terminal · Shell*

```
dotnet new console -n ReadOutlookFiles
cd ReadOutlookFiles
dotnet add package RecursiveAI.OneMail --version 1.0.1
```

Replace `Program.cs` with:

*Program.cs · .NET 10*

```
using System;
using System.IO;
using System.Text;
using RecursiveAI.OneMail.Mapi;
using RecursiveAI.OneMail.Msg;
 
var message = new MapiMessage();
message.Properties.Add(MapiProperty.Create(
    new MapiTag(MapiPid.MessageClass, MapiType.UnicodeString),
    Encoding.Unicode.GetBytes("IPM.Note")));
message.Properties.Add(MapiProperty.Create(
    new MapiTag(MapiPid.Subject, MapiType.UnicodeString),
    Encoding.Unicode.GetBytes("Weekly update")));
 
message.Properties.Add(MapiProperty.Create(
    new MapiTag(MapiPid.MessageFlags, MapiType.Integer32),
    new byte[4]));
 
File.WriteAllBytes("message.msg", MsgWriter.ToArray(message));
File.WriteAllBytes("template.oft", MsgWriter.ToArray(
    message, new MsgWriterOptions { Template = true }));
 
foreach (string path in new[] { "message.msg", "template.oft" })
{
    if (!MsgFile.TryOpen(path, out MsgFile? file, out var defects))
    {
        Console.WriteLine($"{path}: could not open ({defects.Count} defects)");
        continue;
    }
    using (file)
    {
        file!.ReadEverything();
        int? flags = file.Message.GetInt32(MapiPid.MessageFlags);
        string unsent = flags is int value
            ? ((value & 0x00000008) != 0).ToString()
            : "unknown";
        Console.WriteLine(
            $"{path}: Unsent={unsent} | {file.Message.Subject}");
        foreach (var defect in file.Defects)
            Console.WriteLine(defect);
    }
}
```

*Terminal · Shell*

```
dotnet run
```

Output:

*Output · dotnet run*

```
message.msg: Unsent=False | Weekly update
template.oft: Unsent=True | Weekly update
```

The program starts with the unsent flag clear; `Template = true` sets it in the OFT. `GetInt32(MapiPid.MessageFlags)` reads the flags, and `0x00000008` selects the unsent bit. A missing flags property prints `unknown`. To inspect existing files, replace the two paths in the loop and remove the creation section.

`Unsent=True` reports an unsent item, not a definitive template classification. The unsent flag is not a universal OFT detector: Outlook-saved templates can omit it, so `False` or `unknown` does not prove a file is an MSG. The [1.0.1 format reference](https://github.com/recursive-ai-oss/onemail-csharp/blob/fe2e40ab5837ca7e9e9641c1dcdfccf209094f89/docs/msg.md#layout-written-ms-oxmsg-21-24) distinguishes the flag from the root storage’s template identifier.

## What is an MSG file?

An MSG file holds a message’s fields, called MAPI properties, such as its subject and body. Recipients, attachments and embedded messages have their own storage areas. Its outer container follows MS-CFB, Microsoft’s compound-file format: one file holding named streams of data and storage areas. MS-OXMSG is Microsoft’s specification for how message data is arranged inside that container. The subject and message class are properties, not fields in a plain-text email header. OneMail exposes them through its MAPI model. The [documented layout](https://github.com/recursive-ai-oss/onemail-csharp/blob/fe2e40ab5837ca7e9e9641c1dcdfccf209094f89/docs/msg.md#layout-read-ms-oxmsg-21-24) includes the root property stream, value streams and child storages.

## What is an OFT file?

An OFT is a reusable Outlook item that you fill in to create a new message.

The distinction is more than its filename: OneMail’s `Template = true` writer sets the root storage’s template class ID (CLSID), an identifier that marks the file as a template, `0006F046-0000-0000-C000-000000000046`. A normal message file uses `00020D0B-0000-0000-C000-000000000046`. The writer also sets `MSGFLAG_UNSENT`, a flag marking the message as not yet sent. These details are specified in the [1.0.1 writer documentation](https://github.com/recursive-ai-oss/onemail-csharp/blob/fe2e40ab5837ca7e9e9641c1dcdfccf209094f89/docs/msg.md#layout-written-ms-oxmsg-21-24).

Do not confuse the root storage CLSID with the MAPI `MessageClass` property. Both a mail message and a mail template can have `IPM.Note`, meaning a mail item, as their message class. The template CLSID identifies the template storage; `MessageClass` describes the item type. Reading `IPM.Note` alone does not tell you whether the file is an OFT.

## OFT vs MSG: which should you use?

- **Keep an MSG** when your goal is to retain or inspect an Outlook item and its properties.
- **Use an OFT** when your goal is a reusable starting item, rather than a record of a particular message.
- **Use the same parser for both** when extracting their subjects, bodies, recipients or attachments. Template handling does not require a second message decoder.

Renaming `message.msg` to `message.oft` does not set a template CLSID or change its properties. For template output, write it with the template option. For input, inspect the content rather than trusting the extension: [`MsgFile.IsMsg` checks for a compound file with a root property stream](https://github.com/recursive-ai-oss/onemail-csharp/blob/fe2e40ab5837ca7e9e9641c1dcdfccf209094f89/docs/msg.md#using-it), and never consults the extension. That check recognizes the shared message structure, not a separate OFT format.

## Opening a file is not the same as reading all its content

`TryOpen` initially reads the directory and top-level property stream. Recipients, attachments, embedded messages and value streams are read on demand. The example calls `ReadEverything()` before listing `file.Defects` so findings from those children are included. A successful open is not a promise that every child is intact. See the [damage policy](https://github.com/recursive-ai-oss/onemail-csharp/blob/fe2e40ab5837ca7e9e9641c1dcdfccf209094f89/docs/msg.md#damage-policy) for typed findings such as a missing value stream or truncated property stream.

For an attachment-processing workflow, continue with the [MSG reading recipe](https://recursiveai.org/onemail/cookbook/read-msg-file/) and [attachment extraction recipe](https://recursiveai.org/onemail/cookbook/extract-attachments/). The [MSG and OFT reference](https://recursiveai.org/onemail/docs/msg/) covers code pages, embedded messages and reader limits.

## Can Outlook open both?

File parsing and an Outlook version’s UI support are separate questions. Microsoft’s current [new Outlook and Outlook on the web instructions](https://support.microsoft.com/en-us/outlook/mail/open-eml-msg-and-oft-files-in-new-outlook-and-outlook-on-the-web) describe opening both MSG and OFT files and note a qualifying Microsoft 365 subscription requirement. Check those instructions for your application rather than assuming an old Outlook limitation applies today.

For programmatic inspection, start with [OneMail’s getting-started guide](https://recursiveai.org/onemail/docs/getting-started/).
