I'm using a cftry catch to send an email to our alerts box when a widget on our site fails to load.
the cfcatch.message and cfcatch.detail don't provide enough detail on which page in particular is failing.
We have an attribute r_page which returns the page id when output.
However the email is generated using CFScript. How do i call <cfoutput>"#r_page#"</cfoutput> within my script to display in the email body?
<cfscript>
mailObj = new mail();
mailObj.setFrom(application.errorEmail);
mailObj.setTo(application.errorEmail);
mailObj.setSubject("THIS IS THE SUBJECT");
mailObj.setBody("A page is broken. Details: " & cfcatch.detail & " Message: "& cfcatch.message);
mailObj.send();
</cfscript>
Thanks
If you don't quote it, it will be evaluated automatically in the setBody() method, just like your current cfcatch members are being evaluated.
<cfscript>
mailObj = new mail();
mailObj.setFrom(application.errorEmail);
mailObj.setTo(application.errorEmail);
mailObj.setSubject("THIS IS THE SUBJECT");
mailObj.setBody("A page is broken. - " & r_page & " Details: " & cfcatch.detail & " Message: "& cfcatch.message);
mailObj.send();
</cfscript>
You can also evaluate it inline too using ##.
<cfscript>
mailObj = new mail();
mailObj.setFrom(application.errorEmail);
mailObj.setTo(application.errorEmail);
mailObj.setSubject("THIS IS THE SUBJECT");
mailObj.setBody("A page is broken. - #r_page# Details: " & cfcatch.detail & " Message: "& cfcatch.message);
mailObj.send();
</cfscript>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With