public static void Run()
{
// ExStart:ExecuteWithRegionsDataTable
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_MailMergeAndReporting();
string fileName = "MailMerge.ExecuteWithRegions.doc";
Document doc = new Document(dataDir + fileName);
int orderId = 10444;
// Perform several mail merge operations populating only part of the document each time.
// Use DataTable as a data source.
DataTable orderTable = GetTestOrder(orderId);
doc.MailMerge.ExecuteWithRegions(orderTable);
// Instead of using DataTable you can create a DataView for custom sort or filter and then mail merge.
DataView orderDetailsView = new DataView(GetTestOrderDetails(orderId));
orderDetailsView.Sort = "ExtendedPrice DESC";
doc.MailMerge.ExecuteWithRegions(orderDetailsView);
dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
doc.Save(dataDir);
// ExEnd:ExecuteWithRegionsDataTable
Console.WriteLine("\nMail merge executed successfully with repeatable regions.\nFile saved at " + dataDir);
}
// ExStart:ExecuteWithRegionsDataTableMethods