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.
Unfortunately, activation email could not send to your email. Please try again.

ImageMerge problem

Thread ID:





74221 Jun 3,2008 06:20 PM Jun 4,2008 12:48 AM Windows Forms 1
Tags: DocIO
Administrator [Syncfusion]
Asked On June 3, 2008 06:20 PM

I am in trouble with mail merging images. There is no problem with images form database. But when I am using the code below the mailmerge causes an "ArgumentException" exception.

DataTable dt2 = new DataTable(); dt2.Columns.Add("Photo1",typeof(System.Byte[]));
dt2.TableName = "Photos";
DataRow dr2;
dr2 = dt2.NewRow();
FileStream fs = new FileStream("1.gif",FileMode.Open);
BinaryReader br = new BinaryReader(fs);
dr2["Photo1"] = br.ReadBytes((int)br.BaseStream.Length));
dr2["Photo2"] = br.ReadBytes((int)br.BaseStream.Length));
br = null;
fs = null;


The i have configured merge fields in word document like in your emloyeesreport example.
where is the problem ? cany ou give me an advice about merging an external image form hdd to the merge field (Image:Photo1) of word document template.

Thank you

Bhuvaneswari P [Syncfusion]
Replied On June 4, 2008 12:48 AM

Hi Lokelse,

Thank you for your interest in SYncfusion products.

I am able to reproduce the issue. This is due to the image is not converted to bytes properly. Please refer the below code snippet to do so:


FileStream fs = new FileStream(@"..\..\Nature.jpg",FileMode.Open);
byte[] inByte = new byte[fs.Length];
fs.Read(inByte, 0, inByte.Length);
dr2["Photo1"] = inByte;
dr2["Photo2"] = inByte;

Here is the sample for your reference:


Please try this and let us know if this helps you.

Best Regards,


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.

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.