dump to mail |
Ketan Jetty
enthusiasm for technology
|
||
functions
|
|||
|
dump to mail The DumpToMail() is created to help developers dump coldfusion objects to a mail for debugging purpose. You can dump objects like cfcatch, query, query result, session, variables and any coldfusion variables using this function.
DumpToMail()
<!--- dumpToMail :: dumps a max of 5 objects to a mail id. --->
<cffunction name="dumpToMail" access="public">
<cfargument name="data1" required="no" type="any">
<cfargument name="data2" required="no" type="any">
<cfargument name="data3" required="no" type="any">
<cfargument name="data4" required="no" type="any">
<cfargument name="data5" required="no" type="any">
<cfargument name="mailto" required="no" type="string">
<!--- replace the email id ---->
<cfset var emailto = "kjetty@yahoo.com">
<cfif IsDefined("arguments.mailto") AND IsValid("email",arguments.mailto) GT 0>
<cfset emailto = "#arguments.mailto#">
</cfif>
<cfsavecontent variable="dumpVar">
<cfoutput>
Time: #now()#<p>
<cfif IsDefined("arguments.data1")><cfdump var="#arguments.data1#"><hr></cfif>
<cfif IsDefined("arguments.data2")><cfdump var="#arguments.data2#"><hr></cfif>
<cfif IsDefined("arguments.data3")><cfdump var="#arguments.data3#"><hr></cfif>
<cfif IsDefined("arguments.data4")><cfdump var="#arguments.data4#"><hr></cfif>
<cfif IsDefined("arguments.data5")><cfdump var="#arguments.data5#"><hr></cfif>
</cfoutput>
</cfsavecontent>
<cfmail from="support@ketanJetty.com" to="#emailto#" subject="dump email - #now()#" type="text/html">
#dumpVar#
</cfmail>
</cffunction>
How to use DumpToMail() in your code
<!--- how to use dumpToMail --->
<cfset monitorObj = CreateObject("component","monitor")>
1. dump mail to custom mail [optional]
<cfset monitorObj.dumpToMail("arg1", "arg2", "arg3", "arg4", "arg5", "[kjetty@yahoo.com]")>
2. dump mail upto 5 objects
<cfset monitorObj.dumpToFile("arg1", "arg2", "arg3", "arg4", "arg5")>
// change the email in the dumpToMail() to your email id
3. dump mail 2 objects
<cfset monitorObj.dumpToMail("arg1", "arg2")>
Result:
A mail will be sent to the provided email id, containing the dump info.
|
|
||
| Ketan Jetty @ 2010. All Rights Reserved. | |||