Jan 4, 2012

onError cfmail errors to yourself in ColdFusion in cfscript

I'm sure lots of people do the same thing as I do. In onError I eMail myself the errors ( and some other scopes ) so when errors occur on my application I can address them. Moving to script means I can have my entire Application.cfc in script how ever this introduced a small issue. Basically what I do is into the body of an email. With script it's a little more involved but still works eg: You'll notice that I added output = true to the method annotation. I don't think that should be needed infact it works as expected in Railo. It's strange and not consistent with the tag implementation. I think its a bug in ACF. Before adding the annotation I was receiving my emails as expected but the body was always empty. Update Upon further investigation the code quoted above does not actually work. I think the actually issue is in mail.addPart(); However this code works just fine:

2 comments:

  1. You can use the output paramater of writedump to write to a file (ram://#createUuid()#) and then read that back in to to use as the boyd argument in mail.addPart().
    That should remove the need to use savecontent, and so you wont need the output=true

    Tom
    P.S. Can't comment using google account in FireFox, just get a tiny red box above the entry box.
    ReplyDelete
  2. @Tom thanks. Personally I think the savecontent method is less work but the ram drive is handy.
    ReplyDelete