Click or drag to resize

MailMergeExecute Method (Object)

Executes a mail merge operation with specified data source.

Namespace:  SautinSoft.Document.MailMerging
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 5.2.2.16
Syntax
public void Execute(
	Object dataSource
)

Parameters

dataSource
Type: SystemObject
The mail merge data source.
Examples
Generates a table report with regions based on DOCX template and XML document as data source in C#
using System;
using System.Data;
using System.IO;
using SautinSoft.Document;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            TableReportWithRegions();
        }

        /// <summary>
        /// Generates a table report with regions using XML document as a data source.
        /// </summary>
        /// <remarks>
        /// See details at: https://www.sautinsoft.com/products/document/help/net/developer-guide/mail-merge-table-report-with-regions-net-csharp-vb.php
        /// </remarks>
        public static void TableReportWithRegions()
        {
            // Create the Dataset and read the XML.
            DataSet ds = new DataSet();

            ds.ReadXml(@"..\..\Orders.xml");

            // Load the template document.
            string templatePath = @"..\..\InvoiceTemplate.docx";

            DocumentCore dc = DocumentCore.Load(templatePath);

            // Execute the mail merge.
            dc.MailMerge.Execute(ds.Tables["Order"]);

            string resultPath = "Invoices.pdf";

            // Save the output to file
            dc.Save(resultPath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(resultPath) { UseShellExecute = true });
        }
    }
}
Generates a table report with regions based on DOCX template and XML document as data source in VB.Net
Imports System
Imports System.Data
Imports System.IO
Imports SautinSoft.Document

Namespace Sample
    Friend Class Sample
        Shared Sub Main(ByVal args() As String)
            TableReportWithRegions()
        End Sub

        ''' <summary>
        ''' Generates a table report with regions using XML document as a data source.
        ''' </summary>
        ''' <remarks>
        ''' See details at: https://www.sautinsoft.com/products/document/help/net/developer-guide/mail-merge-table-report-with-regions-net-csharp-vb.php
        ''' </remarks>
        Public Shared Sub TableReportWithRegions()
            ' Create the Dataset and read the XML.
            Dim ds As New DataSet()

            ds.ReadXml("..\Orders.xml")

            ' Load the template document.
            Dim templatePath As String = "..\InvoiceTemplate.docx"

            Dim dc As DocumentCore = DocumentCore.Load(templatePath)

            ' Execute the mail merge.
            dc.MailMerge.Execute(ds.Tables("Order"))

            Dim resultPath As String = "Invoices.pdf"

            ' Save the output to file
            dc.Save(resultPath)

            ' Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(resultPath) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also