public static void Run()
{
// ExStart:NestedMailMergeCustom
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_MailMergeAndReporting();
string fileName = "NestedMailMerge.CustomDataSource.doc";
// Create some data that we will use in the mail merge.
CustomerList customers = new CustomerList();
customers.Add(new Customer("Thomas Hardy", "120 Hanover Sq., London"));
customers.Add(new Customer("Paolo Accorti", "Via Monte Bianco 34, Torino"));
// Create some data for nesting in the mail merge.
customers[0].Orders.Add(new Order("Rugby World Cup Cap", 2));
customers[0].Orders.Add(new Order("Rugby World Cup Ball", 1));
customers[1].Orders.Add(new Order("Rugby World Cup Guide", 1));
// Open the template document.
Document doc = new Document(dataDir + fileName);
// To be able to mail merge from your own data source, it must be wrapped
// Into an object that implements the IMailMergeDataSource interface.
CustomerMailMergeDataSource customersDataSource = new CustomerMailMergeDataSource(customers);
// Now you can pass your data source into Aspose.Words.
doc.MailMerge.ExecuteWithRegions(customersDataSource);
dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
doc.Save(dataDir);
// ExEnd:NestedMailMergeCustom
Console.WriteLine("\nMail merge performed with nested custom data successfully.\nFile saved at " + dataDir);
}