Hi Suganya,
Thanks again for the response.
Our problem with the approach taken in the sample provided is that it's basically just providing them with a Word document that has all the merge fields added to the document body itself, as opposed to having the merge fields available to be selected via the "Mailings->Insert Merge Field" menu item. The issue is that once the user starts editing the template within Word, if they delete a mergefield, and then later want to re-reference it, they'd need to remember the exact name of the field and then manually create the merge field through Word's GUI. Also they wouldn't be able to use the "Mailings->Rules" menu item to do things like "If Then Else" statements.
Another product we've been evaluating allows us to configure the mail merge settings of the document, setting it up so it can be bound to a separate .csv file, enabling the "Mailings->Insert Merge Field" menu item like so:
string[] fieldNames = new string[] { "Field1", "Field2", "Field3" };
Document doc = new Document();
doc.MailMergeSettings.DataType = MailMergeDataType.TextFile;
doc.MailMergeSettings.MainDocumentType = MailMergeMainDocumentType.FormLetters;
doc.MailMergeSettings.DataSource = "schema.csv";
doc.MailMergeSettings.Query = string.Format(@"SELECT * FROM {0}", "schema.csv");
for (var i = 0; i < fieldNames.Length; i++)
{
OdsoFieldMapData mapData = new OdsoFieldMapData();
mapData = new OdsoFieldMapData();
mapData.Column = i;
mapData.MappedName = fieldNames[i];
mapData.Name = fieldNames[i];
mapData.Type = OdsoFieldMappingType.Column;
doc.MailMergeSettings.Odso.FieldMapDatas.Add(mapData);
}
MemoryStream mStream = new MemoryStream();
doc.Save(mStream, SaveFormat.Docx);
Then, when you open the document, Word will attempt to open the datasource "schema.csv" file (which is just an empty comma delimited file with the field names residing in the same directory), and the "Mailings->Insert Merge Field" and other menu items are enabled and the user is free to pick and choose which fields they want to reference as the create the template.
Does DocIO allow us to configure the mail merge settings of the document like this, where we can specify that we want it bound to a separate .csv file?
Thanks,
Dan