Rich Text Editor / Mail Merge / Mail Merge Data Sources
In This Topic
    Mail Merge Data Sources
    In This Topic

    Mail Merge Data Sources are files/databases, which contain the data that should be used by the mail merge process. NOV Text Editor currently provides support for the following data source formats:

    When needed you can easily add support for more formats by implementing the abstract NDataSourceFormat class and registering your data source format using its static Register method.

     Loading a Data Source

    For the mail merge feature to work you should load a data source into the rich text document's mail merge object. The code below demonstrates how to load a CSV file embedded as a resource and set some field mappings:

    Load Mail Merge Data Source
    Copy Code
    // Load a mail merge data source from resource
    Stream stream = NResources.Instance.GetResourceStream("RSTR_Employees_csv");
    NDataSource dataSource = NDataSourceFormat.Csv.LoadFromStream(stream, new NDataSourceLoadSettings(null, null, true));
    
    // Create the field mappings
    NMailMergeFieldMap fieldMap = new NMailMergeFieldMap();
    
    fieldMap.Set(ENMailMergeDataField.CourtesyTitle, "TitleOfCourtesy");
    fieldMap.Set(ENMailMergeDataField.FirstName, "FirstName");
    fieldMap.Set(ENMailMergeDataField.LastName, "LastName");
    fieldMap.Set(ENMailMergeDataField.City, "City");
    
    dataSource.FieldMap = fieldMap;
    documentBlock.MailMerge.DataSource = dataSource;
    
    See Also