Mail merge with ContentControls

So I’ve noticed that you now support ContentControls in the form of StructuredDocumentTags. The SDT’s in a word document also have a tag attribute visible.
I am attempting to do a mail merge from a DataTable to a template (word document).
I have only been able to find documentation on the mail merge feature being used with the “Merge Field” type. Can this work with the SDT since the SDT’s do have a tag which can be referenced it should be straightforward to do the association. The template cannot be modified due to requirements.
Using the latest version of Aspose.Words 13.3.0 not beta.

Hi,

Thanks for your inquiry. Please note that Aspose.Words tries to mimic the same behaviour as MS Word do. The Mail Merge and content controls (StructuredDocumentTag) are two different features of Aspose.Words. Please read about Mail Merge in Aspose.Words from here:
https://docs.aspose.com/words/net/mail-merge-and-reporting/

The StructuredDocumentTag Class represents a structured document tag (SDT or content control) in a document. The StructuredDocumentTag.Tag property specifies a tag associated with the current SDT node. A tag is an arbitrary string which applications can associate with SDT in order to identify it without providing a visible friendly name.

You can add/modify contents of content controls (StructuredDocumentTag) by using Aspose.Words. Here is the code to insert plain text and select the Drop Down List item from the content control:

Document doc = new Document(@"c:\test\SDTs.docx");
foreach(StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true, true))
{
    if (sdt.SdtType == SdtType.PlainText)
    {
        sdt.RemoveAllChildren();
        Paragraph para = sdt.AppendChild(new Paragraph(doc)) as Paragraph;
        Run run = new Run(doc, "new text goes here");
        para.AppendChild(run);
    }
    else if (sdt.SdtType == SdtType.DropDownList)
    {
        SdtListItem secondItem = sdt.ListItems[2];
        sdt.ListItems.SelectedValue = secondItem;
    }
}
doc.Save(@"c:\test\out.docx");