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, and modify the text or flow of the document as they see fit. Then they’d 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 this is possible with Aspose.

I found this post from 2011: Define list of mail merge fields available in template

But that was 4+ years ago, and my hope is that this is now possible without requiring a separate data-source file to be downloaded as well.

Thanks,
Dan

Hi Dan,

Thanks for your inquiry. We suggest you please read following articles about mail merge.
http://www.aspose.com/docs/display/wordsnet/Prepare+a+Document
http://www.aspose.com/docs/display/wordsnet/How+to++Execute+Simple+Mail+Merge
http://www.aspose.com/docs/display/wordsnet/Mail+Merge+with+Regions+Explained
http://www.aspose.com/docs/display/wordsnet/How+to++Execute+Mail+Merge+with+Regions

Please use MailMerge.Execute method with data source object e.g DataTable, DataView to perform a simple mail merge. Hope this helps you. In this case, there is no need of separate data source file e.g csv, xlsx etc.

If you still face problem, please share your template and expected output documents along with some more detail about your scenario here for our reference. We will then provide you more information about your query along with code.

Hi Tahir,


Thanks for the quick response, it’s much appreciated.

I’ve gone through the articles and examples, and while helpful, none quite seem to address my needs.

Specifically, our users who are going to be editing and creating these letter templates may not know what MailMerge fields are available to them to use. 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.

The only way I’ve read this is possible is by downloading a separate datasource file and configuring the word doc’s MailMergeSettings to query that file and have the OdsoFieldMapData be bound to fields from that datasource file.

Is there another way to do this, without requiring a separate datasource file?

Thanks,
Dan

Hi Dan,

Thanks for your inquiry.

dhartley:
The only way I’ve read this is possible is by downloading a separate datasource file and configuring the word doc’s MailMergeSettings to query that file and have the OdsoFieldMapData be bound to fields from that datasource file.
Yes, you can achieve your requirements by using this approach.
dhartley:
Is there another way to do this, without requiring a separate datasource file?
If you do not want to use MailMergeSettings, you need to import all data source files into database and perform mail merge as shared in my previous post. Please use MailMerge.Execute method with data source object e.g DataTable, DataView to perform a simple mail merge. If you are only using CSV as data source, you can import it into DataTable using .NET APIs and perform mail merge.

1) Share your document with your customer.
2) Your customer may add mail merge fields in the document and upload it to your system.
3) Your system must have data source with all fields which your customer add to document in the form of DataTable, DataView etc.
4) Perform the mail merge using MailMerge.Execute method.

You can easily achieve your requirements by using MailMergeSettings and MailMerge.Execute method.

Hope this answers your query. Please let us know if you have any more queries.

Hi Tahir,

Thanks again for the response.

I understand I can perform the mail merge using a datasource like a DataTable or DataView, etc. My question is more concerned with the creation of the template itself. The problem is we want to guide our users during the template creation process (steps 1 & 2 of what you outlined in your last post), so that they can easily make use of Word's "Mailings" tab, click the "Insert Merge Field" button/arrow, and see a list of available fields that they could select from.

Again, this is during the creation of the template. After they create it, they will upload it, and we will process it on the server, obviously fetching the real data from the database and performing the actual mail merge to generate the letters. I've already got this side of it complete for our POC, and it works fine.

However, the issue is that it requires our users to know exactly which mail merge fields they can utilize during the creation of the template, which is a lot to ask of them as there could 50-100 fields we want to make available to them. To help them during the template creation process, from what I have found, our options appear to be limited to having them download a separate empty/columns-only datasource file, which the template can be configured to query, which will then show the available list of fields in the "Mailings" tab "Insert Merge Field" drop down.

Is there any other way to accomplish this?

Thanks,
Dan

Hi Dan,

Thanks for your inquiry. Please note hat Aspose.Words for .NET is a class library that enables your applications to perform a great range of document processing tasks. Aspose.Words supports DOC, DOCX, RTF, HTML, OpenDocument, PDF, XPS, EPUB and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without utilizing Microsoft Word®.


In your case, I suggest you please use the same approach which you shared here to achieve your requirements. Hope this helps you.

The only way I’ve read this is possible is by downloading a separate datasource file and configuring the word doc’s MailMergeSettings to query that file and have the OdsoFieldMapData be bound to fields from that datasource file.