We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Coldfusion Mail Merge using query and multiple values

I’m currently evaluating aspose for word using coldfusion


Under the title " Simple Mail Merge"

How do I send multiple values of this;

<cfset values=[ "Alexey Noskov" , "Aspose" , "Auckland" ]>

To achieve multiple pages in the output document. It only allows me to send one.

Can this be done using a coldfusion query ?


Please read the following article about mail merge and check overloaded methods of MailMerge.execute. Hope this helps you.
How to Execute Mail Merge

I did check those two links out however I’m not understanding the query that is passed into the MailMerge.execute() function.

I write a simple coldfusion query and pass it in and I get an error which says:

The execute method was not found.
Either there are no methods with the specified method name and argument types or the execute method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

I’m wondering if this function is expecting the query object to be in a certain type of format, i.e. different to what coldfusion creates.

Here is an example of my code: For testing I’ve just got two merge fields in the word document firstname and surname

select firstname, surname from member objDoc = CreateObject("java", "com.aspose.words.Document").init("/www/memberletter.docx"); objDoc.getMailMerge().execute(qMember); objDoc.save('/www/#createUUID()#.doc');

If I use the following syntax it works ok though I would like the data to come from a DB query;

objDoc = CreateObject("java", "com.aspose.words.Document").init("/www/membertletter.docx"); mergeFieldNames = ["firstname","surname"]; mergeFieldValues = ["Mary","Smith"]; objDoc.getMailMerge().execute(mergeFieldNames,mergeFieldValues);

Any help you could give me would be great.

All my script tags got truncated, let me know if you need any explanation.


You can view it here.

Merging Data from a ResultSet

In Aspose.Words a ResultSet object produced from a database query is passed to the mail merge engine by first wrapping it in a new instance of the DataTable class. The DataTable constructor accepts a ResultSet object and also the name of the table as a string.

Regarding the above. Is it expecting a Coldfusion query to be wrapped ina . DataTable class. How do I achieve this ?


We are working over your query and will get back to you soon.


In your case, you need to use the MailMerge.execute(com.aspose.words.net.System.Data.DataTable table) method. Please check the last example in the following article.
ColdFusion and Aspose.Words for Java