Mail Merge: generate a simple envelope using C# and Document .Net.
 
PRODUCTS   DOWNLOAD PURCHASE SUPPORT BLOG  COMPANY  
 
Overview
Download
Purchase
Code Examples
Create
Load
Save as
Convert
Merge
Digital Signature
PDF/A Compliance
Protect and Security
Document Properties
Find and Replace
Reporting and Mail Merge
API Reference
Version History

"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.



Requirements and Technical Information

Document .Net is compatible with all .Net languages and supports all OS (Windows, MacOS and Linux) where .Net Framework or .Net Core can be used. It's entirely written in managed C#, which makes it absolutely standalone and independent.

.Net Framework 4.0 and higher and .Net Core 2.0 and higher

.Net Framework 4.0, 4.5, 4.6.1 and higher.

.Net Core 2.0 and higher.



Reasonable prices

     The library offers for developers comprehensive API to do all what they want with DOCX, RTF, HTML, 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 - Standard Edition starts from $530.


Download

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

 

 
Products Support Company Contact

  • Sweden, Stockholm
  • Mortviksvagen 68B 142 43 SKOGAS
  • Sales & Support:
  • Tel: +46 766922352
  • Email:
  • sales@sautinsoft.com support@sautinsoft.com
  •       
    Copyright © 2002 - 2019 SautinSoft (started from sautin.com). All rights reserved.