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

item seperator after last item when performing Mail merge for a group

I have a list of persons, and I want to have this list merged into my word document in a way that each person should be placed on a separate line. Assuming my list consists of the persons "Alice" and "Bob", my resulting file could look like " A list of persons: Alice Bob " How would my word file have to look like to allow that? If my file looks like " A list of persons: {MERGEFIELD BeginGroup:Persons}{MERGEFIELD FirstName} {MERGEFIELD EndGroup:Persons} " the result will look like " A list of persons: Alice Bob " Notice the unwanted empty line at the end. On the other hand, if my file looked like "A list of persons: {MERGEFIELD BeginGroup:Persons}{MERGEFIELD FirstName}, {MERGEFIELD EndGroup:Persons}" the result would be "A list of persons: Alice, Bob, " I don't want the "separator" to be applied after the last item as well, just as ",".Join() would apply it to the last item. (Sidenote: After I edited this post to add some information, all newlines vanished (even though they were visible in the editor before saving), which makes the post unreadable and much less comprehensible. Adding them all again doesn't work, so I'm sorry that if something might be incomprehensible.)

2 Replies

SK Sebastian Kieritz June 14, 2017 09:17 AM UTC

This is how my last posting should look like, but I can't format it that way again.


SY Sethumanikkam Yogendran Syncfusion Team June 15, 2017 10:12 AM UTC

Hi Sebastian,

Thank you for contacting Syncfusion support.

Regarding empty line after Mail merge:
To remove empty paragraphs, you can use the “RemoveEmptyParagraphs” and “RemoveEmptyGroup” properties from MailMerge which will remove the paragraphs and groups which contains empty merge field values in Word document while performing Mail merge.

Regarding remove separator for last item while performing the Mail merge:
To remove separator in the group (i.e after merge field), you can use Event support which will allows you to work with merge fields and its owners while performing Mail merge.

We have prepared the sample to illustrate the same, please find the sample from below link and let us know if this helps you.
Sample link
Note: Please find the input template in “App_Data” folder and code snippets in “Default.aspx.cs” file in the application.

Please refer our UG link to know more about Event support in Mail merge.

If we misunderstood any of your requirement, then kindly provide us sample or modified sample of above along with data’s used at your end and screenshot/output Word document of the expected result which will helpful to provide you the appropriate solution at the earliest.

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


Loader.
Up arrow icon