I have create a document using MailMerge. I want to read the values of all the fieldsin the document that have created using MailMerge. How do ido that?
Thanks for your request. Yes, you can, but there is no direct way. You can use the same approach as used here:
Hope this will help. In case of any ambiguity, please let us know.
I just wanted to be more clear on my question. I am trying to read the content of the mail merge field after execution. Please see the code and comments below
Document doc = new Document(templateStream);
// load just created document
Document doc = new Document(outputStream);
// Now here i want read the merge field name & its content
// i'm not sure document will still have the merge fields after execution
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>DocumentBuilder<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> builder = new DocumentBuilder(doc);<o:p></o:p>
foreach (string fieldName in doc.MailMerge.GetFieldNames())
builder.MoveToMergeField(fieldName, false, false);
builder.MoveToMergeField(fieldName, true, false);
foreach (Bookmark bookmark in doc.Range.Bookmarks)
// Retrieve the field name and the merged field value using the bookmark.
string fieldName = bookmark.Name;
string fieldValue = bookmark.Text;