Hi Lc,
Thank you for contacting Syncfusion support.
Currently DocIO doesn’t provide support for html formatted string in mail merge. Alternatively you shall achieve this through mail merge event handler during mail merge. Kindly use the following code example to achieve the same.
Code example:
document.MailMerge.MergeField += MailMerge_MergeField
document.MailMerge.ExecuteNestedGroup(dataTable)
Event Handler code:
Private Sub MailMerge_MergeField(sender As Object, args As MergeFieldEventArgs)
If args.FieldName = "HTMLFieldName" Then
'Gets the Html String
Dim HTMLtext As String = TryCast(args.FieldValue, String)
'Gets the index of the owner paragraph of the current merge field
Dim paraIndex As Integer = args.CurrentMergeField.OwnerParagraph.OwnerTextBody.ChildEntities.IndexOf(args.CurrentMergeField.OwnerParagraph)
'Gets the index of the current merge field
Dim paraItemIndex As Integer = args.CurrentMergeField.OwnerParagraph.ChildEntities.IndexOf(args.CurrentMergeField)
'Inserts the html string at the specified location
args.CurrentMergeField.OwnerParagraph.OwnerTextBody.InsertXHTML(HTMLtext, paraIndex, paraItemIndex)
'Clears the text
args.Text = String.Empty
End If
End Sub
Regards,
Sathish