e.FieldValue Is Nothing

Hi -
I am using the MailMerge class to replace a field in a word document <Image:ClientLogo>. I have added a handler for the event but when the event is fired, the e.FieldValue property is nothing. The element in the values object array for the data is a byte array (of a jpg). I have also tried placing a string in the element, but that returned nothing as well.

When stepping through the code, the element in the array does contain the correct data, but it appears to be lost when calling the Merge.

Any ideas or suggestions?

** code
Dim templateDoc As Aspose.Word.Document
Dim fields As String()
Dim values As Object()

Me.GetMergeItems(pObject:=pObject, pFields:=fields, pValues:=values)

templateDoc = New Aspose.Word.Document(stream:=New System.IO.MemoryStream(Buffer:=pObject.TemplateDocumentData))

AddHandler templateDoc.MailMerge.MergeImageField, AddressOf HandleMergeImageFieldEvent

templateDoc.MailMerge.Execute(fieldNames:=fields, values:=values)

Handler Code **
Private Sub HandleMergeImageFieldEvent(ByVal sender As Object, ByVal e As Aspose.Word.MergeImageFieldEventArgs)
e.ImageStream = _
New System.IO.MemoryStream(Buffer:=CType (e.FieldValue,Byte()))
End Sub

e.FieldValue will only be null in the event handler when mail merge did not find the field in the data source (in the object array in your case).
Make sure the field name in fields[] is “ClientLogo”, because “Image:” is just a prefix that is needed in the document to distinguish normal fields from image fields.

THANKS!
That was the problem…the mergefield was named Image:ClientLogo and I had used the same when creating the fields array.

Thanks again for your prompt response

Big Smile