Create DOCX using Mail merge in C#

High-speed .NET library for merging document templates and user data into files of various formats

Our solution provides a powerful platform independent API. Use our Mail merge document API to develop high-level software for .NET and .NET Core platforms. This is a powerful software solution for merging templates in Word and PDF formats and data from custom data sources and further exporting the result to DOCX, PDF, HTML and other popular formats using C#.

View code snippet

Mail merge in DOCX using C#

With our product API, you can create personalized documents using the Mail merge DOCX template, data from a custom data sources and Mail merge feature in C#. Mail merge DOCX template is a document in DOCX format with merge fields – special fields where you want to insert personalized data from your data source.

The data source is a custom data store from which data is pulled during the Mail merge operation to be substituted into appropriate fields of DOCX template.

Report generation

You can build reports based on Mail merge DOCX using the merge operation. Simply create an DOCX template with merge fields that can be used for report generation and select your data source. You can even generate reports from Excel data if you collect it there.

Try Mail merge for DOCX file in C#

To try our Mail merge feature, load a DOCX template with merge fields and fill in these fields through our interface. After running the code, export the report in a convenient format generated using C#.

The following example shows how to perform a Mail merge operation in C#:

Execute a Mail merge operation using docx template in C#
Upload a Mail merge template
Run code
Select the target format from the list
using Aspose.Words;

var fields = new string[]
{
};
var values = new object[]
{
};

var doc = new Document("Input.docx");
doc.MailMerge.Execute(fields, values);
doc.Save("Output.docx");
Run code

How to use Mail merge in DOCX files

  1. Install Aspose.Words for .NET.
  2. Add a library reference (import the library) to your C# project.
  3. Create a DOCX merge template with merge fields.
  4. Open the template file in C#.
  5. Call the Execute() method, passing the merge fields and their values there.
  6. Call the Save() method, passing an output filename with required extension.
  7. Get the result of Mail merge operation as DOCX file.

C# library to use Mail merge in DOCX

There are three alternative options to install "Aspose.Words for .NET" onto your system. Please choose one that resembles your needs and follow the step-by-step instructions:

System Requirements

Our product is fully cross-platform and supports all major .NET implementations:

  • .NET ≥ 5.0
  • .NET Core ≥ 2.0
  • .NET Standard ≥ 2.0
  • .NET Framework ≥ 3.5
  • MonoMac
  • MonoAndroid
  • Xamarin

As far as .NET code doesn't depend on the underlying hardware or operating system, but only on a Virtual Machine, you are free to develop any kind of software for Windows, macOS, Android, iOS and Linux. Just make sure you have installed the corresponding version of .NET Framework, .NET Core, Windows Azure, Mono or Xamarin.

We recommend using Microsoft Visual Studio, Xamarin, and MonoDevelop integrated development environments to create C#, F#, VB.NET applications.

Fore more details please refer to Product Documentation.

Other supported file formats

You can perform Mail merge operation for other file formats:

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2024. All Rights Reserved.