MailMerger.ExecuteToImages

MailMerger ExecuteToImages method. Performs a mail merge operation for a single record and renders the result to images.

ExecuteToImages(string, ImageSaveOptions, string[], object[], MailMergeOptions)

Performs a mail merge operation for a single record and renders the result to images.

public static Stream[] ExecuteToImages(string inputFileName, ImageSaveOptions saveOptions, 
    string[] fieldNames, object[] fieldValues, MailMergeOptions mailMergeOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
saveOptionsImageSaveOptionsThe output’s save 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.
mailMergeOptionsMailMergeOptionsMail merge options.

Examples

Shows how to fill a template with data by executing a simple mail merge using an array data source and saving the result as image streams.

string[] names = new string[] { "FirstName", "SecondName", "Position" };
string[] values = new string[] { "James", "Bond", "Spy" };

Stream[] pages = MailMerger.ExecuteToImages(MyDir + "MailMergeTemplate.docx", new ImageSaveOptions(SaveFormat.Png), names, values);

See Also


ExecuteToImages(Stream, ImageSaveOptions, string[], object[], MailMergeOptions)

Performs a mail merge operation for a single record and renders the result to images.

public static Stream[] ExecuteToImages(Stream inputStream, ImageSaveOptions saveOptions, 
    string[] fieldNames, object[] fieldValues, MailMergeOptions mailMergeOptions = null)
ParameterTypeDescription
inputStreamStreamThe input file stream.
saveOptionsImageSaveOptionsThe output’s save 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.
mailMergeOptionsMailMergeOptionsMail merge options.

Examples

Shows how to fill a template loaded from stream with data by executing a simple mail merge using an array data source and saving the result as image streams.

string[] names = new string[] { "FirstName", "SecondName", "Position" };
string[] values = new string[] { "James", "Bond", "Spy" };

using (Stream input = File.OpenRead(MyDir + "MailMergeTemplate.docx"))
{
    Stream[] pages = MailMerger.ExecuteToImages(input, new ImageSaveOptions(SaveFormat.Png), names, values);
}

See Also


ExecuteToImages(string, ImageSaveOptions, DataRow, MailMergeOptions)

Performs mail merge from a DataRow into the document and renders the result to images.

public static Stream[] ExecuteToImages(string inputFileName, ImageSaveOptions saveOptions, 
    DataRow dataRow, MailMergeOptions mailMergeOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
saveOptionsImageSaveOptionsThe output’s save 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.
mailMergeOptionsMailMergeOptionsMail merge options.

Examples

Shows how to fill a template with data by executing a simple mail merge using a DataRow data source and saving the result as image streams.

DataTable dt = new DataTable();
dt.Columns.Add("FirstName");
dt.Columns.Add("SecondName");
dt.Columns.Add("Position");
DataRow dr = dt.Rows.Add("James", "Bond", "Spy");

Stream[] pages = MailMerger.ExecuteToImages(MyDir + "MailMergeTemplate.docx", new ImageSaveOptions(SaveFormat.Png), dr);

See Also


ExecuteToImages(Stream, ImageSaveOptions, DataRow, MailMergeOptions)

Performs mail merge from a DataRow into the document and renders the result to images.

public static Stream[] ExecuteToImages(Stream inputStream, ImageSaveOptions saveOptions, 
    DataRow dataRow, MailMergeOptions mailMergeOptions = null)
ParameterTypeDescription
inputStreamStreamThe input file stream.
saveOptionsImageSaveOptionsThe output’s save 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.
mailMergeOptionsMailMergeOptionsMail merge options.

Examples

Shows how to fill a template loaded from stream with data by executing a simple mail merge using a DataRow data source and saving the result as image streams.

DataTable dt = new DataTable();
dt.Columns.Add("FirstName");
dt.Columns.Add("SecondName");
dt.Columns.Add("Position");
DataRow dr = dt.Rows.Add("James", "Bond", "Spy");

using (Stream input = File.OpenRead(MyDir + "MailMergeTemplate.docx"))
{
    Stream[] pages = MailMerger.ExecuteToImages(input, new ImageSaveOptions(SaveFormat.Png), dr);
}

See Also


ExecuteToImages(string, ImageSaveOptions, DataTable, MailMergeOptions)

Performs mail merge from a DataRow into the document and renders the result to images.

public static Stream[] ExecuteToImages(string inputFileName, ImageSaveOptions saveOptions, 
    DataTable dataTable, MailMergeOptions mailMergeOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
saveOptionsImageSaveOptionsThe output’s save 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.
mailMergeOptionsMailMergeOptionsMail merge options.

Examples

Shows how to fill a template with data by executing a simple mail merge using a DataTable data source and saving the result as image streams.

DataTable dt = new DataTable();
dt.Columns.Add("FirstName");
dt.Columns.Add("SecondName");
dt.Columns.Add("Position");
dt.Rows.Add("James", "Bond", "Spy");
dt.Rows.Add("John", "Doe", "Unknown");

Stream[] pages = MailMerger.ExecuteToImages(MyDir + "MailMergeTemplate.docx", new ImageSaveOptions(SaveFormat.Png), dt);

See Also


ExecuteToImages(Stream, ImageSaveOptions, DataTable, MailMergeOptions)

Performs mail merge from a DataRow into the document and renders the result to images.

public static Stream[] ExecuteToImages(Stream inputStream, ImageSaveOptions saveOptions, 
    DataTable dataTable, MailMergeOptions mailMergeOptions = null)
ParameterTypeDescription
inputStreamStreamThe input file stream.
saveOptionsImageSaveOptionsThe output’s save 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.
mailMergeOptionsMailMergeOptionsMail merge options.

Examples

Shows how to fill a template loaded from stream with data by executing a simple mail merge using a DataTable data source and saving the result as image streams.

DataTable dt = new DataTable();
dt.Columns.Add("FirstName");
dt.Columns.Add("SecondName");
dt.Columns.Add("Position");
dt.Rows.Add("James", "Bond", "Spy");
dt.Rows.Add("John", "Doe", "Unknown");

using (Stream input = File.OpenRead(MyDir + "MailMergeTemplate.docx"))
{
    Stream[] pages = MailMerger.ExecuteToImages(input, new ImageSaveOptions(SaveFormat.Png), dt);
}

See Also