Mail merge images not being displayed

fred williams

Hello,
I've created a mail merge application as per he example on your website.

The Word document is loaded in, and the docprovider is set. I then insert images fine using insert>picture and they show up in the document. Everything appears fine form within the program.

When I send the emails however, the pictures don't show up. From within Outlook I get an error that reads:

"the linked image cannot be displayed. The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location."

I've attached a screenshot of exactly how I'm inserting the image into the document. Below is the code I use when I send the emails. Also noteworthy, I had to change the formatprovider from docx to rtf before sending the emails. If I use the docxformatprovider, the text in the email shows up with a bunch of symbols, improperly formatted.

Martin Ivanov

Your code is mostly connected to the way you send the document. Furthermore, there are some inconsistencies and missing lines, such as the fact that you are using RtfFormatProvide to export the document and specifying "text/html" as the MIME type. When it comes to obtaining a string with the RTF content of the document, you can just use the overloaded method of RtfFormatProvider which returns a string, instead of exporting it to a byte array, writing the byte array to a stream and getting the string through a StringBuilder.

In case you would like to insert the picture as a merge field, i.e. to have different pictures in the mail merged document depending on the current record, you should use a field as shown in the snippet below:

MergeField mf = new MergeField();

mf.PropertyPath = "RecipientPhoto";

IncludePictureField picField = new IncludePictureField();

picField.SetPropertyValue(IncludePictureField.ImageUriProperty, mf);

this.editor.InsertField(picField);

I am also sending you a solution so you can check how the mail merge data source is organized. Note that the nested fields in mail merge are introduced in the last version of the controls.

Regards,
Martin
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.