How to: Programmatically Mark the Data Source as Use for Mail Merge
- 2 minutes to read
Set the IDataDispatcherOptions.DataSourceName property to the name of the data source (the DataSourceInfo.DataSourceName property) to use the data source for mail merge.
Note
We do not recommend using data sources which are not marked as Use for Mail Merge to perform mail merge.
// Set the Application data source which cannot be edited or removed by the end-user.
this.snapControl1.DataSource = dsContacts.Tables[0];
// Add Document data sources which persist for the currently loaded document only.
this.snapControl1.Document.BeginUpdateDataSource();
this.snapControl1.Document.DataSources.Add("Products", products);
this.snapControl1.Document.DataSources.Add("Categories", categories);
this.snapControl1.Document.DataSources.Add("Sales", myExcelSource);
this.snapControl1.Document.EndUpdateDataSource();
// Set the default (Application) data source as the mail merge source ("Use for Mail Merge" option).
this.snapControl1.Options.SnapMailMergeVisualOptions.DataSourceName = "";
// Uncomment the following line to set the Sales data source as the mail merge source.
// this.snapControl1.Options.SnapMailMergeVisualOptions.DataSourceName = "Sales";