We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Feature Request for Mail Merge / Mail Merge Group and XHTML

Thread ID:





120649 Sep 30,2015 11:41 AM UTC Sep 30,2015 03:37 PM UTC ASP.NET MVC 1
Tags: DocIO
Asked On September 30, 2015 11:41 AM UTC


currently i'm using some random string in mail merge to replace xhtml parts later on with xhtml from our database.  This is something like this:

Dim textDictionary As New Dictionary(Of String, String)
Dim uid = TokenGenerator.NewGuid.ToString

While textDictionary.ContainsKey(uid)
    uid = TokenGenerator.NewGuid.ToString
End While

textDictionary.Add(uid, textToAdd)
temp.Text = "<<TempHTML_" & uid & ">>" 'temp is one element of my model as list

 Dim dataTable = New MailMergeDataTable("MainCategory", model)

doc.Open(currentFilePath, FormatType.Automatic)
doc.MailMerge.RemoveEmptyGroup = True
doc.MailMerge.RemoveEmptyParagraphs = True

For Each entry In textDictionary
    Dim selection As TextSelection = doc.Find(New System.Text.RegularExpressions.Regex("<<TempHTML_" & entry.Key & ">>"))
    If Not IsNothing(selection) Then
        Dim OwnerParagraph As WParagraph = selection.GetAsOneRange().OwnerParagraph
        If TypeOf OwnerParagraph.OwnerTextBody Is WTextBody Then
            Dim tb As WTextBody = TryCast(OwnerParagraph.OwnerTextBody, WTextBody)
        End If
    End If

Is there some way to get my xhtml directly into mail merge? Is there a chance to get some dircet function for inserting xhtml in mail merge?

Kinf regards,

Sathish K [Syncfusion]
Replied On September 30, 2015 03:37 PM UTC

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


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



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon