Personalized document
Merge an address into the template
Change the recipient data and create a personalized document. The browser sends data only; the template and merge operation stay on the server.
Template structureUnderstand the current template
Explore its merge fields, repeating blocks, and nested structure in an interactive template map.
Inspector
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Separate templates from application data
MailMerge combines a reusable Word-compatible template with business data. Designers control the document layout while application code supplies strongly typed values at runtime.
The merge is performed in memory with ServerTextControl. No browser editor, temporary document, or client-side template processing is required.
API used
MailMerge.MergeObject
Key members
MailMerge receives a ServerTextControl as its text component and maps object properties to fields in the loaded template.
using var textControl = new ServerTextControl();
textControl.Create();
using var mailMerge = new MailMerge
{
TextComponent = textControl
};
mailMerge.LoadTemplate(templatePath,
FileFormat.InternalUnicodeFormat);
mailMerge.MergeObject(new
{
firstname = request.FirstName.Trim(),
name = request.LastName.Trim(),
company = request.Company.Trim()
});
mailMerge.SaveDocumentToMemory(out byte[] document,
BinaryStreamType.InternalUnicodeFormat,
new SaveSettings());
How it works
The endpoint validates the request, loads its fixed template, maps request properties to matching merge-field names, and returns the resulting Internal Unicode Format document as Base64.