Execute

Execute(string, string, string[], object[])

Performs a mail merge operation for a single record.

public static void Execute(string inputFileName, string outputFileName, string[] fieldNames, 
    object[] fieldValues)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
fieldNamesString[]Array of merge field names. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.
fieldValuesObject[]Array of values to be inserted into the merge fields. Number of elements in this array must be the same as the number of elements in fieldNames.

Examples

Shows how to do mail merge operation for a single record.

// There is a several ways to do mail merge operation:
string doc = MyDir + "Mail merge.doc";

string[] fieldNames = new string[] { "FirstName", "Location", "SpecialCharsInName()" };
string[] fieldValues = new string[] { "James Bond", "London", "Classified" };

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.1.docx", fieldNames, fieldValues);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.2.docx", SaveFormat.Docx, fieldNames, fieldValues);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, fieldNames, fieldValues);

See Also


Execute(string, string, SaveFormat, string[], object[])

Performs a mail merge operation for a single record.

public static void Execute(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    string[] fieldNames, object[] fieldValues)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
fieldNamesString[]Array of merge field names. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.
fieldValuesObject[]Array of values to be inserted into the merge fields. Number of elements in this array must be the same as the number of elements in fieldNames.

Examples

Shows how to do mail merge operation for a single record.

// There is a several ways to do mail merge operation:
string doc = MyDir + "Mail merge.doc";

string[] fieldNames = new string[] { "FirstName", "Location", "SpecialCharsInName()" };
string[] fieldValues = new string[] { "James Bond", "London", "Classified" };

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.1.docx", fieldNames, fieldValues);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.2.docx", SaveFormat.Docx, fieldNames, fieldValues);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, fieldNames, fieldValues);

See Also


Execute(string, string, SaveFormatMailMergeOptions, string[], object[])

Performs a mail merge operation for a single record.

public static void Execute(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    MailMergeOptions mailMergeOptions, string[] fieldNames, object[] fieldValues)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
mailMergeOptionsMailMergeOptionsMail merge options.
fieldNamesString[]Array of merge field names. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.
fieldValuesObject[]Array of values to be inserted into the merge fields. Number of elements in this array must be the same as the number of elements in fieldNames.

Examples

Shows how to do mail merge operation for a single record.

// There is a several ways to do mail merge operation:
string doc = MyDir + "Mail merge.doc";

string[] fieldNames = new string[] { "FirstName", "Location", "SpecialCharsInName()" };
string[] fieldValues = new string[] { "James Bond", "London", "Classified" };

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.1.docx", fieldNames, fieldValues);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.2.docx", SaveFormat.Docx, fieldNames, fieldValues);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMerge.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, fieldNames, fieldValues);

See Also


Execute(Stream, Stream, SaveFormat, string[], object[])

Performs a mail merge operation for a single record.

public static void Execute(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    string[] fieldNames, object[] fieldValues)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
fieldNamesString[]Array of merge field names. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.
fieldValuesObject[]Array of values to be inserted into the merge fields. Number of elements in this array must be the same as the number of elements in fieldNames.

Examples

Shows how to do mail merge operation for a single record from the stream.

// There is a several ways to do mail merge operation using documents from the stream:
string[] fieldNames = new string[] { "FirstName", "Location", "SpecialCharsInName()" };
string[] fieldValues = new string[] { "James Bond", "London", "Classified" };

using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStream.1.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, fieldNames, fieldValues);

    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStream.2.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, fieldNames, fieldValues);
}

See Also


Execute(Stream, Stream, SaveFormatMailMergeOptions, string[], object[])

Performs a mail merge operation for a single record.

public static void Execute(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    MailMergeOptions mailMergeOptions, string[] fieldNames, object[] fieldValues)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
mailMergeOptionsMailMergeOptionsMail merge options.
fieldNamesString[]Array of merge field names. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.
fieldValuesObject[]Array of values to be inserted into the merge fields. Number of elements in this array must be the same as the number of elements in fieldNames.

Examples

Shows how to do mail merge operation for a single record from the stream.

// There is a several ways to do mail merge operation using documents from the stream:
string[] fieldNames = new string[] { "FirstName", "Location", "SpecialCharsInName()" };
string[] fieldValues = new string[] { "James Bond", "London", "Classified" };

using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStream.1.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, fieldNames, fieldValues);

    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStream.2.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, fieldNames, fieldValues);
}

See Also


Execute(string, string, DataRow)

Performs mail merge from a DataRow into the document.

public static void Execute(string inputFileName, string outputFileName, DataRow dataRow)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
dataRowDataRowRow that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataRow.

// There is a several ways to do mail merge operation from a DataRow:
string doc = MyDir + "Mail merge.doc";

DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.1.docx", dataRow);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.2.docx", SaveFormat.Docx, dataRow);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataRow);

See Also


Execute(string, string, SaveFormat, DataRow)

Performs mail merge from a DataRow into the document.

public static void Execute(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    DataRow dataRow)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
dataRowDataRowRow that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataRow.

// There is a several ways to do mail merge operation from a DataRow:
string doc = MyDir + "Mail merge.doc";

DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.1.docx", dataRow);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.2.docx", SaveFormat.Docx, dataRow);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataRow);

See Also


Execute(string, string, SaveFormatMailMergeOptions, DataRow)

Performs mail merge from a DataRow into the document.

public static void Execute(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    MailMergeOptions mailMergeOptions, DataRow dataRow)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
mailMergeOptionsMailMergeOptionsMail merge options.
dataRowDataRowRow that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataRow.

// There is a several ways to do mail merge operation from a DataRow:
string doc = MyDir + "Mail merge.doc";

DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.1.docx", dataRow);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.2.docx", SaveFormat.Docx, dataRow);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataRow.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataRow);

See Also


Execute(Stream, Stream, SaveFormat, DataRow)

Performs a mail merge operation for a single record.

public static void Execute(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    DataRow dataRow)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
dataRowDataRowRow that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataRow using documents from the stream.

// There is a several ways to do mail merge operation from a DataRow using documents from the stream:
DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamDataRow.1.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, dataRow);

    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamDataRow.2.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataRow);
}

See Also


Execute(Stream, Stream, SaveFormatMailMergeOptions, DataRow)

Performs a mail merge operation for a single record.

public static void Execute(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    MailMergeOptions mailMergeOptions, DataRow dataRow)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
mailMergeOptionsMailMergeOptionsMail merge options.
dataRowDataRowRow that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataRow using documents from the stream.

// There is a several ways to do mail merge operation from a DataRow using documents from the stream:
DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamDataRow.1.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, dataRow);

    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamDataRow.2.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataRow);
}

See Also


Execute(string, string, DataTable)

Performs mail merge from a DataTable into the document.

public static void Execute(string inputFileName, string outputFileName, DataTable dataTable)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
dataTableDataTableTable that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataTable.

// There is a several ways to do mail merge operation from a DataTable:
string doc = MyDir + "Mail merge.doc";

DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.1.docx", dataTable);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.2.docx", SaveFormat.Docx, dataTable);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataTable);

See Also


Execute(string, string, SaveFormat, DataTable)

Performs mail merge from a DataRow into the document.

public static void Execute(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    DataTable dataTable)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
dataTableDataTableTable that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataTable.

// There is a several ways to do mail merge operation from a DataTable:
string doc = MyDir + "Mail merge.doc";

DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.1.docx", dataTable);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.2.docx", SaveFormat.Docx, dataTable);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataTable);

See Also


Execute(string, string, SaveFormatMailMergeOptions, DataTable)

Performs mail merge from a DataRow into the document.

public static void Execute(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    MailMergeOptions mailMergeOptions, DataTable dataTable)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
mailMergeOptionsMailMergeOptionsMail merge options.
dataTableDataTableTable that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataTable.

// There is a several ways to do mail merge operation from a DataTable:
string doc = MyDir + "Mail merge.doc";

DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.1.docx", dataTable);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.2.docx", SaveFormat.Docx, dataTable);
MailMerger.Execute(doc, ArtifactsDir + "LowCode.MailMergeDataTable.3.docx", SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataTable);

See Also


Execute(Stream, Stream, SaveFormat, DataTable)

Performs a mail merge operation for a single record.

public static void Execute(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    DataTable dataTable)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
dataTableDataTableTable that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataTable using documents from the stream.

// There is a several ways to do mail merge operation from a DataTable using documents from the stream:
DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeDataTable.1.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, dataTable);

    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeDataTable.2.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataTable);
}

See Also


Execute(Stream, Stream, SaveFormatMailMergeOptions, DataTable)

Performs a mail merge operation for a single record.

public static void Execute(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    MailMergeOptions mailMergeOptions, DataTable dataTable)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
mailMergeOptionsMailMergeOptionsMail merge options.
dataTableDataTableTable that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored.

Examples

Shows how to do mail merge operation from a DataTable using documents from the stream.

// There is a several ways to do mail merge operation from a DataTable using documents from the stream:
DataTable dataTable = new DataTable();
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("Location");
dataTable.Columns.Add("SpecialCharsInName()");

DataRow dataRow = dataTable.Rows.Add(new string[] { "James Bond", "London", "Classified" });

using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeDataTable.1.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, dataTable);

    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeDataTable.2.docx", FileMode.Create, FileAccess.ReadWrite))
        MailMerger.Execute(streamIn, streamOut, SaveFormat.Docx, new MailMergeOptions() { TrimWhitespaces = true }, dataTable);
}

See Also