We have been using the Apose.Word mailmerge feature to insert images into documents. However, we have recently upgraded Aspose.Word to version 184.108.40.206 from 220.127.116.11 and now the image mailmerge no longer works. Any ideas?
Simple C# Console Sample.
static void Main(string args)
src = new Document(@“c:\asposetest.doc”);
src.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MailMerge_MergeImageField);
string fields = new string;
string values = new string;
fields = “Hello1”; values = “Hello1”;
fields = “Hello2”; values = “Hello2”;
fields = “Hello3”; values = “Hello3”;
fields = “Hello4”; values = “Hello4”;
fields = “Hello5”; values = “Hello5”;
src = null;
private static void MailMerge_MergeImageField(object sender, MergeImageFieldEventArgs e)
System.Diagnostics.Debug.WriteLine("Image field detected “+e.FieldName+” val "+e.FieldValue);
The diagnostic message never gets printed and the debugger doesn’t get tripped for the event handler.
It works fine in our tests. Please double check that the merge field in the document is named like this "Image:MyFieldName" (press Alt+F9 to see field codes in MS Word and check then).
Yep, it is. These files have been working fine whilst we have been using 1.6 since it was released. It was only with the installation recently that they stopped working.
I’ve tried with the existing working templates, and new template generated solely for testing, and it just doesn’t get called. I can package up the dlls and source with a template if you think it might help.
I’ve got your files here and will test in the next 1-2 days.
Ok, I see the point.
A side effect of one of the recent changes we’ve made is that the merge field event is no longer fired for fields that are not found in the data source.
We realize it became inconvenient and will make sure it is called again in one of the next hotfixes.
In the meantime you can workaround if you add a field named RossTest to your list of fields you pass to mail merge.
OK that does appear to work round it. I presume I’ll have to change it when the hotfix version is available?
I think this workaround will keep working okay when I change back to fire event for non existant fields.
Aspose.Word 2.1.13 is out that fires the event handler for all fields found in the document regardles of whether they were found in the data source or not, for more info see http://aspose.com/blogs/Roman.Korchagin/archive/2005/02/23/532.aspx