Free Support Forum - aspose.com

Can't use an ashx in mailmerge

Hi,

I'm using an ashx to get images in a mailmerge. It is something similar to this:

../getImg.ashx?f=picutre.jpg

It gives me an error:

Exception 'Cannot load image from field 'PictureField'. The field contains data in unsupported format. Illegal characters in path.' occured in Aspose.Words for .NET 5.2.2.0.
For free technical support, please post this error and the file in the Aspose.Words Forums
http://www.aspose.com/forums/ShowForum.aspx?ForumID=75.

If I change the route to for example "../picture.jpg", it works fine. And if I run getImg.ashx?f=picutre.jpg at the browser, I can see the image.

This is (reduced), what the ashx does:

context.Response.Clear();
context.Response.ClearContent();
context.Response.Cache.SetExpires(DateTime.Now.AddDays(1));
context.Response.Cache.SetSlidingExpiration(true);
context.Response.Cache.SetValidUntilExpires(true);
context.Response.Cache.VaryByParams["n"] = true;
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.ContentType = "image/Jpeg";
context.Response.AddHeader("Content-Length", pict.Length.ToString());
if (context.Response.IsClientConnected)
{
context.Response.BinaryWrite(pict);
context.Response.Flush();
context.Response.End();
}

┬┐Any idea?

Thanks

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Please try using the full path; see the following code:

Document doc = new Document(@"C:\Temp\in.doc");

doc.MailMerge.Execute(new string[] { "Test" }, new string[] { "http://localhost:2295/getImg.ashx" });

doc.Save(@"C:\Temp\out.doc");

I use the latest version of Aspose.Words (9.2.0) for testing. You can download this version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,