We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

IMailMergeDataSource - Insert Image/ Value Of Merged Field

Hello,

I’m using IMailMergeDataSource to produce a mail merge. I use merge fields in a word document.

Everything is working fine except I need to be able to add an image to the word document.

I have a space in the word document to display an image. The image is not saved in the database.

Is it possible to add an image to the word document using IMailMergeDataSource?

Also is it possible to get a value of a merged field?

Thanks in advance

Hi Roslyn,


Thanks for your inquiry. I have attached a template Word document that contains a sample Image MERGEFIELD here for your reference. You can implement IFieldMergingCallback interface, get the value of MERGEFIELD and add an image by placing/running the following code inside IFieldMergingCallback.ImageFieldMerging event:

private class HandleImageMergeField : IFieldMergingCallback<o:p></o:p>

{<o:p></o:p>

void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)<o:p></o:p>

{<o:p></o:p>

// Do nothing.<o:p></o:p>

}<o:p></o:p>

void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)<o:p></o:p>

{<o:p></o:p>

e.ImageFileName = e.FieldValue.ToString();<o:p></o:p>

}<o:p></o:p>

}


I hope, this helps.

Best regards,