I am not able to mailmerge using ExecuteWithRegion for a table in which rows get added based on rows in DataTable item

I have DataTable item which has rows and columns(NameAdd, FamilyRelationName,Age, Share) but it is not merging the values in the document

Aspose.Words.Document doc = new Aspose.Words.Document(eFilePath);
var gratuityFamilyDetails = await objRes.Result.Item2.ReadAsync<GratuityFamilyDetails>();
List<GratuityFamilyModel> gratuityFamilyData = AssignToModel(gratuityFamilyDetails.Cast<GratuityFamilyDetails>().ToList());
//gratuityFamilyData = gratuityFamilyDetails;
DataTable item = ConvertToDataTable(gratuityFamilyData);
var placeHolders = new string[] { "Salutation", "FirstName", "MiddleName", "LastName", "EmployeeCode", "Gender", "Religion", "MaritalStatus", "Department", "Desig", "DateofJoining", "Address" };
// set the actual values  for Statement
var actualValues = new string[] { gratuityDetailsObj.Salutation.ToString(), gratuityDetailsObj.FirstName.ToString(), gratuityDetailsObj.MiddleName.ToString(), gratuityDetailsObj.LastName.ToString(), gratuityDetailsObj.EmployeeCode.ToString(), GetGender(gratuityDetailsObj.Gender), gratuityDetailsObj.Religion.ToString(), gratuityDetailsObj.MaritalStatus.ToString(), gratuityDetailsObj.Department.ToString(), gratuityDetailsObj.Designation.ToString(), gratuityDetailsObj.DateofJoining.ToString("dd/MM/yyyy"), gratuityDetailsObj.Address.ToString() };
doc.MailMerge.Execute(placeHolders, actualValues);
doc.MailMerge.ExecuteWithRegions(item);

please help

@shubham98 Could you please attach your template and sample data source (you can save DataTable as XML) here for testing? We will check the issue and provide you more information.

thanks for the reply the issue was resolved.

1 Like