Mailmerge with image in dotnet core

Hi Guys,

I'm trying to update a mailmerge field in a Word document with an image but can't seem to get it to work. I've found your example here. I've tried using the Image class from System.Drawing.Image (from the System.Drawing.Common Package) and from your own Syncfusion.Drawing.Image, but in both cases the mailmerge field is untouched. The field has the 'Image:' prefix. Which type do I need to use in dotnet core to be able to use an image with mailmerge?

5 Replies

DB Dilli Babu Nandha Gopal Syncfusion Team July 11, 2018 04:57 PM UTC

Hi Raymond, 

Thank you for contacting Syncfusion support. 

Yes, it is possible to have image in mail merge execution. The field should have ‘Image’ prefix in its field code. We have prepared a sample for your requirement which can be downloaded from the following link. 

In this sample we have done the following things: 
  1. Loads a template Word document using DocIO(MailMergeWithImage\Data\ MailMergeEventTemplate.doc). 
  2. Executes mail merge in the document. 
  3. Saves the Word document (inside MailMergeWithImage\Output). 

You can also refer our online sample which illustrates your requirement. Please find the sample here

Please let us know if you have any questions. 

Regards, 
Dilli babu. 



RD Raymond den Haan July 11, 2018 08:06 PM UTC

Hi Dilli babu,

Thanks for the sample. It seems that in you're sample you reference to the image files already located on the hard disk by sending a string with the name. Is it also possible to use something like a byte[] or an Image type? like in the example here: https://help.syncfusion.com/file-formats/docio/working-with-mailmerge.
The images I need to use aren't stored locally and if possible I'd like to avoid that.


DB Dilli Babu Nandha Gopal Syncfusion Team July 12, 2018 09:44 AM UTC

Hi Raymond, 

Thank you for your update. 

Currently, Image type can’t be directly used in mail merge operation for ASP.NET Core platform. Instead image’s byte array can be used for mail merging the image fields in your business object. A memory stream must be created with image’s byte array and set to ImageStream property of MergeImageFieldEventArgs instance.  The sample illustrating above behavior can be downloaded from the following link. 

To know more about MergeImageField and its usage, kindly refer our UG documentation which is available here

Kindly provide us your confirmation whether the sample fulfils your requirement and let us know if you have any questions. 

Regards, 
Dilli babu. 



RD Raymond den Haan July 16, 2018 10:12 AM UTC

Hi Dilli babu,

Thanks, writing the stream to the field within the mailmerge event works.


DB Dilli Babu Nandha Gopal Syncfusion Team July 16, 2018 10:21 AM UTC

Hi Raymond, 
 
We glad to know that the provided sample fulfills your requirement. Please let us know if you need any further assistance on this. 
 
Regards, 
Dilli babu. 


Loader.
Up arrow icon