Write dump in cfmail with cfscript in ColdFusion

by 9:14 AM 4 comments
I find it handy to dump out a scope and email it to myself. I use this occasionally in Application.cfc in onError() or onMissingTemplate() to dump cgi and the exception variables.

This weekend I was working on a small ColdFusion project and am using cf9. All my cfc's are in script and I wanted to dump full scopes and email them back to myself. Its not as simple as in tags but its a workable solution using savecontent.

I really expected this to just work:

mail.addPart( type="html", charset="utf-8", body=writedump(application) );

But it wont so here is the solution:

Here is the solution:



The other exception to my project was one cfc had to have a udf for cfexecute which also is not yet in cfscript.


Update.

To answer Steves question here is the code example.

You can just attach the report as a file attachment and specify the content.