We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Building an Object Source MailMerge

We have built some helper functions that allow us to reflect on objects using a dot notation. For example we can use something like "Person.Address.City" to retrieve the city for a name. Essentially this is a Person class that has an Address class with the Address class containing a property called "City". By naming my merge fields in a word document using this syntax it's easy to iterate through the merge fields and then get the data using MailMerge.Execute with a list of merge fields and data. The problem I'm running into is with do the same sort of thing with Group merging. For example suppose we had a "Person.Addresses[n].City.Population" This would mean we had a person with multiple addresses and want to return all the population for the cities. I would create a mailmerge . I manually create a datatable from the addresses collection and pass it to MailMerge.ExecuteGroup. If I just use it would return the default City string representation, but when I use it doesn't work. I even tried attaching an event handler to the merge to manually handle this case, but the event it not fired since the merge can not find . Any ideas on how i might handle this?



1 Reply

RA Rajendran Syncfusion Team September 13, 2010 07:30 AM UTC

Hi Larry,

Thank you for using Syncfusion products.

The following must be ensured for mail merge process to work properly.
1. The merge field name and the column name should be the same.
2. Otherwise you have to map the merge fields with the column names.
Code Snippet for Mapping Fields:
//Update the mapping fields
document.MailMerge.MappedFields.Add("CompanyAddress", "Address");

We have prepared a sample to illustrate your requirement. Please do find the sample from below location.

Sample link:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=F963827613530.zip

Please try this and if the problem persists, Could you please update your sample for further analysis?

Please let us know if you have any other questions.

Regards
Rajendran



Loader.
Live Chat Icon For mobile
Up arrow icon