Download the Microsoft Mail Merge Sample Code - Here
I created a new Visual Studio 2010 ASP.NET project, added a new reference to the project by expanding references from the solution explorer and selecting new reference. I selected the COM tab and chose the Microsoft Word 14 reference. This will add 2 new references to the project - Microsoft.Office.Core and Microsoft.Office.Interop.Word.
This example uses the Microsoft MSDN sample code for the basic mail merge functions.
Add a using statement for the newly added reference as follows:
using Word = Microsoft.Office.Interop.Word;
I cut the first four lines of the Microsoft code and pasted it at the beginning of the class declaration to ensure proper scope for these variables.
Next I Selected the Server Explorer tab and created a connection to my local SQL Server and Northwind database.
I added GridView and button controls to the page
Back to the design view - double click on the button on the form and add the following code to the button click event.
In the same button click event that you added the snippet above add all of the code in the button1_click event from the MSDN sample code (not all code shown highlighted below)
Next add the remainder of the MSDN sample code into the aspx page just under the public partial class declaration.
Replace the highlighted code in the CreateMailMergeDataFile with the code shown below
Replace highlighted code with this code
I included my project files but you will have to modify the connection string information to your SQL database if it's not on the local machine in the default SQL instance.