# MailMerge.SaveDocumentToMemory Method

> Saves the merged document.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 14.0
- **Namespace:** `TXTextControl.DocumentServer`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXDocumentServer.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXDocumentServer.dll` from the setup
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl.DocumentServer > MailMerge.SaveDocumentToMemory Method
- **954 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocumenttomemory-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocumenttomemory-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocumenttomemory-method/llms-full.txt

---

### Description

Saves the merged document.

### Syntax

#### SaveDocumentToMemory(out byte\[\], BinaryStreamType, SaveSettings)

Saves the merged document to a byte array.

```csharp
public void SaveDocumentToMemory(out byte[] data, BinaryStreamType fileFormat, SaveSettings saveSettings);
```

```vbnet
Public Sub SaveDocumentToMemory(ByRef data As Byte(), fileFormat As BinaryStreamType, saveSettings As SaveSettings)
```

| Parameter | Description |
|---|---|
| data | Specifies a byte array or a string into which the data is saved. No memory needs to be allocated through the caller. |
| fileFormat | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) or the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) values. |
| saveSettings | Specifies a [SaveSettings](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/llms-full.txt) object with additional information and settings for the save operation. |

#### SaveDocumentToMemory(out string, StringStreamType, SaveSettings)

Saves the merged document to a string.

```csharp
public void SaveDocumentToMemory(out string data, StringStreamType fileFormat, SaveSettings saveSettings);
```

```vbnet
Public Sub SaveDocumentToMemory(ByRef data As String, fileFormat As StringStreamType, saveSettings As SaveSettings)
```

| Parameter | Description |
|---|---|
| data | Specifies a byte array or a string into which the data is saved. No memory needs to be allocated through the caller. |
| fileFormat | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) or the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) values. |
| saveSettings | Specifies a [SaveSettings](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/llms-full.txt) object with additional information and settings for the save operation. |

### Examples

The following example uses Save Document To Memory in a focused Mail Merge workflow.

```csharp
byte[] data = new byte[] { 1 };
mailMerge.SaveDocumentToMemory(out data, BinaryStreamType.WordprocessingML, new SaveSettings());
```

```vbnet
Dim data As Byte() = New Byte() { 1 }
mailMerge.SaveDocumentToMemory(data, BinaryStreamType.WordprocessingML, New SaveSettings())
```

---

## Nearby

- **Previous:** [MailMerge.SaveDocument Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocument-method/llms-full.txt)
- **Next:** [MailMerge.SearchPath Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/searchpath-property/llms-full.txt)
