在CFSCRIPT中发送带有CFMAIL的电子邮件

时间:2014-06-11 22:10:44

标签: coldfusion coldfusion-9

我在工作中编写了一个使用一些CFC的应用程序 - 我遇到了一些错误,但我想实际邮寄错误,因为应用程序是实时的,而且很少发生。

我无法阻止当前正在运行的故障排除。

有没有人有经验/能指出我在cfc / cfscript中做cfmail?更具体地说,在cfscript中的try / catch内部。

我们正在运行ColdFusion 9,它不支持<cfmail>内的<cfscript>

2 个答案:

答案 0 :(得分:7)

mail CFC内置于CF9及以上版本。您可以在cfscript中使用它,并且在实现它的位置无关紧要 - 在onError中,在try / catch块中应该没问题。

Adob​​e在他们的CF9文档中有一个例子:

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0693d5dae123bcd28f6d-7ff9.html

答案 1 :(得分:4)

使用函数编写新的cfc以发送电子邮件,然后将其包含在try / catch中。像下面的东西将起作用

sendMail.cfc(遗漏了很多东西,但这是结构)

<cfcomponent output="false">
  <cffunction name="sendEmail">
    <cfargument name="errorMessage">
    <cfmail>
      <cfdump var="#arguments.errorMessage#">
    </cfmail>
  </cffunction>
</cfcomponent>

try {
  //code here
} catch (any e) {
  var sendEmail = new sendMail();
  sendEmail.sendEmail(e);
}
相关问题