We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose MailMerge field-name matching fails if there is a case(upper-lower etc) mismatch in the template

Hi Team,


If we define any mergefield in the word template in lower case (eg: customer_name) and supplied data to the MailMerge.Execute method is in Caps (eg: CUSTOMER_NAME) then Aspose.MailMerge.Execute(dataTable) is unable to recognize that field and throws an error:

Missing corresponding field
definition. See inner exception for further details.
Inner exception 1: The request
data does not have a matching field definition for the following items from the
template: CUSTOMER_NAME

Aspose.MailMerge.Execute method works fine when the same merge field is defined as all CAPS in the word template. We suspect this is an issue with Aspose. Is the fieldname case-sensitive to the mergefield name? the aspose site (http://www.aspose.com/api/net/words/aspose.words.mailmerging.mailmerge/execute/methods/2) says it is not case-sensitive. if it is not case-sensitive, then any idea why the the field is not recognized if the case doesnt match?

Regards,

Lallan Gupta


Hi Lallan,

Thanks for your inquiry. The field names are not case sensitive. We have tested the scenario using latest version of Aspose.Words for .NET 16.2.0 with following code example and have not found the shared issue. Please use Aspose.Words for .NET 16.2.0.

Document doc = new Document(MyDir + "input.docx");

DataTable dt = new DataTable();

dt.Columns.Add("CUSTOMER_NAME", typeof(String));

DataRow dr = dt.NewRow();

dr["CUSTOMER_NAME"] = "Customer name is James.";

dt.Rows.Add(dr);

doc.MailMerge.Execute(dt);

doc.Save(MyDir + "Out.docx");


If you still face problem, please share your input document and code example to reproduce this issue at our end. We will investigate the issue on our side and provide you more information.