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

MailMerge with predefined field list?

Hi,

My company is evaluating your product and our need is to allow users to manage letter templates (basically, word documents with mail merge fields).  The idea is that they'd be able to download a word doc, which is setup to reference predefined mail-merge fields, allowing our users to reference any of the available fields from a set list.  So, ideally, in Word 2007, we'd want them to be able to go to the "Mailings" tab, click the "Insert Merge Field" button/arrow, and see a list of available fields that they could select from.  Then they'd modify the text or flow of the document as they see fit, upload the document to our system, and we would run it against our data at a later time to produce letters that would be sent to the appropriate recipients. So far I haven't been able to determine if binding a predefined list of mail merge fields is possible with DocIO.  

I found this post from 2009 which seems to indicate it is NOT supported: https://www.syncfusion.com/forums/80753/linking-a-csv-data-source-to-a-word-document

But that was 5+ years ago, and my hope is that this is now possible, is it?

Thanks,
Dan

6 Replies

SR Suganya Rathinam Syncfusion Team November 4, 2015 01:01 PM UTC

Hi Dan,

Thank you for contacting Syncfusion support.

DocIO provides support to perform Mail merge with predefined list of fields. Please find the following online documentation link and sample link for your reference.

Documentation Link:
http://help.syncfusion.com/file-formats/docio/mailmerge

Online Sample Link:
http://mvc.syncfusion.com/demos/web/docio/nestedmailmerge

We have added a sample for creating a template Word document with predefined list of fields from the data source to perform Mail merge in Windows Forms application. If this sample meets you requirement and you need the same in ASP.NET MVC platform, please let us know. We will update you with the sample for your preferred platform.

Sample Link:
http://www.syncfusion.com/downloads/support/directtrac/general/ze/GenerateWord_Windows2049657059.zip

If we misunderstood your requirement, kindly elaborate your requirement with clear description (like screenshot of your output or expected output document). Thereby we will analyze further on your requirement and update you appropriate solution at the earliest.


Please let us know if you have any questions.

Regards,
Suganya



DH Dan Hartley November 4, 2015 04:37 PM UTC

Hi Suganya,

Thank you for the quick reply.

I looked at the documentation and sample you provided, but it doesn't quite address our requirements/needs.  The samples and documentation show how to programmatically insert merge fields into a Word document, but what we need is to allow our users that are creating/editing the document to be able to choose from merge fields provided via the "Mailings->Insert Merge Field" menu item in Word.  

To clarify, our users will be the ones actually creating and maintaining the Word document templates, we just want to provide them with a blank template to start off with that is already setup/configured to have merge fields available from the "Mailings->Insert Merge Field" menu item, which they can then pick and choose from when creating/editing the document inside Microsoft Word.

Is this possible with DocIO?

Thanks,
Dan


SR Suganya Rathinam Syncfusion Team November 5, 2015 09:43 AM UTC

Hi Dan,

Thank you for your update.

DocIO is a non-UI component that provides a full-fledged document instance model similar to the Microsoft Office COM libraries and it is not a Word viewer. In our sample we have inserted the merge fields to the Word document programmatically as similar to MS Word application using DocIO. Please find the below document that illustrates the comparison between MS Word application and our sample from the following link.

http://www.syncfusion.com/downloads/support/directtrac/146472/ze/Forum_121026846743100.zip

If your requirement is to achieve the mentioned scenario in Word document editor, kindly let us know. We will analyze further and update you with the other feasible solutions.

Please let us know if you have any questions.

Regards,
Suganya



DH Dan Hartley November 5, 2015 05:40 PM UTC

Hi Suganya,

Thanks again for the response.

Our problem with the approach taken in the sample provided is that it's basically just providing them with a Word document that has all the merge fields added to the document body itself, as opposed to having the merge fields available to be selected via the "Mailings->Insert Merge Field" menu item.  The issue is that once the user starts editing the template within Word, if they delete a mergefield, and then later want to re-reference it, they'd need to remember the exact name of the field and then manually create the merge field through Word's GUI.  Also they wouldn't be able to use the "Mailings->Rules" menu item to do things like "If Then Else" statements.

Another product we've been evaluating allows us to configure the mail merge settings of the document, setting it up so it can be bound to a separate .csv file, enabling the "Mailings->Insert Merge Field" menu item like so:

            string[] fieldNames = new string[] { "Field1", "Field2", "Field3" };

            Document doc = new Document();

            doc.MailMergeSettings.DataType = MailMergeDataType.TextFile;
            doc.MailMergeSettings.MainDocumentType = MailMergeMainDocumentType.FormLetters;
            doc.MailMergeSettings.DataSource = "schema.csv";
            doc.MailMergeSettings.Query = string.Format(@"SELECT * FROM {0}", "schema.csv");

            for (var i = 0; i < fieldNames.Length; i++)
            {
                OdsoFieldMapData mapData = new OdsoFieldMapData();
                mapData = new OdsoFieldMapData();
                mapData.Column = i;
                mapData.MappedName = fieldNames[i];
                mapData.Name = fieldNames[i];
                mapData.Type = OdsoFieldMappingType.Column;
                doc.MailMergeSettings.Odso.FieldMapDatas.Add(mapData);
            }

            MemoryStream mStream = new MemoryStream();

            doc.Save(mStream, SaveFormat.Docx);

Then, when you open the document, Word will attempt to open the datasource "schema.csv" file (which is just an empty comma delimited file with the field names residing in the same directory), and the "Mailings->Insert Merge Field" and other menu items are enabled and the user is free to pick and choose which fields they want to reference as the create the template.

Does DocIO allow us to configure the mail merge settings of the document like this, where we can specify that we want it bound to a separate .csv file?

Thanks,
Dan




SR Suganya Rathinam Syncfusion Team November 6, 2015 05:35 AM UTC

Hi Dan,

Thank you for your update.

We would like to inform you that currently DocIO doesn’t have any direct API’s for adding custom Mail merge settings and perform mail merge from custom data sources. We have already logged a feature report regarding this. A support incident to track the status of this feature has been created under your account. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents 

Regards,
Suganya



FI Filipe replied to Suganya Rathinam February 24, 2018 02:57 PM UTC

Hi Dan,

Thank you for contacting Syncfusion support.

DocIO provides support to perform Mail merge with predefined list of fields. Please find the following online documentation link and sample link for your reference.

Documentation Link:
http://help.syncfusion.com/file-formats/docio/mailmerge

Online Sample Link:
http://mvc.syncfusion.com/demos/web/docio/nestedmailmerge

We have added a sample for creating a template Word document with predefined list of fields from the data source to perform Mail merge in Windows Forms application. If this sample meets you requirement and you need the same in ASP.NET MVC platform, please let us know. We will update you with the sample for your preferred platform.

Sample Link:
http://www.syncfusion.com/downloads/support/directtrac/general/ze/GenerateWord_Windows2049657059.zip

If we misunderstood your requirement, kindly elaborate your requirement with clear description (like screenshot of your output or expected output document). Thereby we will analyze further on your requirement and update you appropriate solution at the earliest.


Please let us know if you have any questions.

Regards,
Suganya


Ola 

Loader.
Live Chat Icon For mobile
Up arrow icon