Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create word document
            Document document = new Document();

            document.LoadFromFile(@"..\..\..\..\..\..\Data\MergeEventHandler.doc");
            lastIndex = 0;

            List <CustomerRecord> customerRecords = new List <CustomerRecord>();
            CustomerRecord        c1 = new CustomerRecord();

            c1.ContactName = "Lucy";
            c1.Fax         = "786-324-10";
            c1.Date        = DateTime.Now;
            customerRecords.Add(c1);

            CustomerRecord c2 = new CustomerRecord();

            c2.ContactName = "Lily";
            c2.Fax         = "779-138-13";
            c2.Date        = DateTime.Now;
            customerRecords.Add(c2);

            CustomerRecord c3 = new CustomerRecord();

            c3.ContactName = "James";
            c3.Fax         = "363-287-02";
            c3.Date        = DateTime.Now;
            customerRecords.Add(c3);

            //Execute mailmerge
            document.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);
            document.MailMerge.ExecuteGroup(new MailMergeDataTable("Customer", customerRecords));

            //Save doc file.
            document.SaveToFile(@"Sample.doc", FileFormat.Doc);

            //Launching the MS Word file.
            WordDocViewer(@"Sample.doc");
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create word document
            Document document = new Document();
            document.LoadFromFile(@"..\..\..\..\..\..\Data\Fax2.doc");
            lastIndex = 0;

            List<CustomerRecord> customerRecords = new List<CustomerRecord>();
            CustomerRecord c1 = new CustomerRecord();
            c1.ContactName = "Lucy";
            c1.Fax = "786-324-10";
            c1.Date = DateTime.Now;
            customerRecords.Add(c1);

            CustomerRecord c2 = new CustomerRecord();
            c2.ContactName = "Lily";
            c2.Fax = "779-138-13";
            c2.Date = DateTime.Now;
            customerRecords.Add(c2);

            CustomerRecord c3 = new CustomerRecord();
            c3.ContactName = "James";
            c3.Fax = "363-287-02";
            c3.Date = DateTime.Now;
            customerRecords.Add(c3);

            //Execute mailmerge
            document.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);
            document.MailMerge.ExecuteGroup(new MailMergeDataTable("Customer", customerRecords));

            //Save doc file.
            document.SaveToFile(@"Sample.doc", FileFormat.Doc);

            //Launching the MS Word file.
            WordDocViewer(@"Sample.doc");
        }