---
Product: Aspose.Email
Platform: net
Page Type: reference
Canonical URL: https://reference.aspose.org/email/net/msg-writer
---

# MsgWriter

## Overview

`MsgWriter` serializes a `MsgDocument` into a valid `.msg` file. Call `ToBytes` to obtain the serialized content as a byte array for in-memory use, or call `WriteFile` to write directly to a file path. The writer internally builds a `CfbDocument` from the `MsgDocument` tree and delegates the binary serialization to `CfbWriter`.

## Methods

| Signature | Description |
|-----------|-------------|
| `ToBytes(document: MsgDocument)` | Serializes `document` to a valid `.msg` byte array. |
| `WriteFile(document: MsgDocument, path: string)` | Serializes `document` and writes it to the file at `path`. |

## See Also
- [Aspose.Email for .NET — Enterprise API Reference](https://reference.aspose.com/email/net/)