Mail merge in Aspose.Word needs to be able to retrieve a value by a field name. I don’t quite see how to represent name-value pairs using IList in a manner that is generic enough to be useful for many customers. I might allow mail merge to accept IDictionary, but I don’t think this is what you are after.
The IList or IEnumerator contains the objects that are used for
the mailmerge For each object in the IList/IEnumerator you execute code
like this (= the same as a DataSet with multiple records):
What you basically do is:
MSWord contains: MergeField "Contact.LastName", MergeField "Contact.Address.Country.Name"
long id = 100;
Contact contact = GetContactFromWhatEver(id)
Document.MailMerge(contact)
The overloaded mailmerge method just executes on all the fields in the word document.:
result = Eval(contact, mergeFieldFromWord, [formatting])
You have to implement contact.Address.Country.Name yourself in a loop:
object newValue = Eval(contact, "Address");
newValue = Eval(newValue, "Country");
result = Eval(newValue, "Name");
the same is true for contact.Friends[0].Name… Parse it first and
recusirvely execute it with Eval…(i think you need reflection for
this, but i’m not sure)