PRODUCTS   DOWNLOAD PURCHASE SUPPORT BLOG  COMPANY  
 
Key Features
Create DOCX
Create RTF
Convert DOCX <=> RTF
Mail Merge and Reporting
>>Mail Merge: Simple envelope
Download trial
Purchase
Code Samples
Documentation
What's New
Tutorials & Videos
How to generate a DOCX document within .Net and C# (Video).
How to create an RTF document in C# and .Net (Video).
How can a Word (*.docx and *.rtf) document be created in C# and .Net.
Mail Merge: generate a simple envelope using C# and Document .Net.
How programmatically convert between DOCX and RTF in C# using Document .Net library?.

"Mail Merge: generate a simple envelope using C# and Document .Net."

Introduction

Mail Merge is the feature of Document .Net which allows to easy generate documents (reports, letters, envelopes) using templates. For example, it's will be very helpful to generate hundreds of identical documents but with different data.

To illustrate how works Mail Merge function let's create C# application which generates envelopes "Happy New Year" for Simpson family. As result, we'll get 5 (five) same congratulatory envelopes in the single document.

Our steps:

  1. Create an envelope template (envelope-template.docx) in MS Word with Fields "Name" and "FamilyName".
  2. Type C# code which executes Mail Merge between Simpson persons and "envelope-template.docx".
  3. See result: "simpson-family.docx: which contains 5 (five) named envelopes.
    simpson-family.docx

1. Create an envelope template in MS Word: envelope-template.docx

To start, let's open MS Word and create new empty document with name "envelope-template.docx". Next, you may add some images and text, anything what you want to see to gongratulate the Simpson's family. Our main goal is add two Fields "Name" and "FamilyName".

  1. Select "INSERT" tab.
  2. Click by the pictogram "Quick Parts".
  3. Select and click by "Field.." menu item.
  4. In the opened window, follow to the "Field names:" and select "MergeField".
  5. In the "Field name:" type "Name".
  6. Click "OK".

By the same steps, please add another Field with name "FamilyName".

Mail Merge: generate a simple envelope using C# and Document .Net.

2. C# code which executes Mail Merge between Simpson persons and "envelope-template.docx"

            DocumentCore dc = DocumentCore.Load(@"envelope-template.docx");

            var dataSource = new[] { new { Name = "Homer", FamilyName = "Simpson" }, 
                                new { Name = "Marge ", FamilyName = "Simpson" },
                                new { Name = "Bart", FamilyName = "Simpson" },
                                new { Name = "Lisa", FamilyName = "Simpson" },
                                new { Name = "Maggie", FamilyName = "Simpson" }};

            dc.MailMerge.Execute(dataSource);
            dc.Save(@"Simpson-family.docx");

Here we create an array of objects by anonymous type. After execution of mail merge method we'll get the same number of copies document with filled fields as number of objects in the array.

3. See result: "simpson-family.docx"

Mail Merge: generate a simple envelope using C# and Document .Net.

Files to download: envelope-template.docx, simpson-family.docx.



Requrements and Technical Information

     Requires only .Net 4.0 or above. Our product is compatible with all .Net languages and supports all Operating Systems where .Net Framework can be used.

Note that «Document .Net» is entirely written in managed C#, which makes it absolutely standalone and an independent library. Of course, No dependency on Microsoft Word.



Reasonable prices

     The library offers for developers comprehensive API to do all what they want with DOCX, RTF, PDF and Text formats at reasonably prices. The main point of interest is that «Document .Net» is less expensive than all of its more or less popular counterparts. For example, a single license of Document .Net - DOCX Edition cost $330, Document .Net - RTF Edition also cost $330 and the Total Edition starts from $890.


Download

To see this functionality firsthand, download the freshest «Document .Net» with code examples, 12.3 Mb.

 

 
Products Downloads Support Company
Buy now
Follow us on Google Plus SautinSoft on Facebook SautinSoft on Twitter SautinSoft on Youtube Our Blog
Copyright © 2002 - 2017 SautinSoft (started from sautin.com). All rights reserved.