混淆何时在cfmail中使用cfoutput



我不能100%确定何时使用cfoutput以及如何在下面的示例中使用cfoutput。是否应该将整个cfmail包装在cfoutput中?

Background:我有一个基于if语句发送电子邮件的函数。电子邮件的消息具有来自cfquery的变量。

 <cffunction name="emailUpdate" access="public" returntype="string">
    <cfargument name="usr_email" required="yes">
    <cfargument name="status_update" required="yes">
    <cfargument name="form_id" required="yes">

    <cfquery name="emailformData" datasource="RC">
      SELECT    *
      FROM      Basic_Info
      WHERE      ID = <cfqueryparam value="#ARGUMENTS.form_id#">
    </cfquery>
    <cfoutput query="emailformData">   
      <cfmail 
        from="forms@email.us" 
        to="#usr_email#" 
        subject="Status Update"> 
        <cfif status_update EQ 'Submitted'>
          Form Submitted: The following quote request ID: #emailformData.ID#  has been submitted on
          #emailformData.Submission_Date# for the following party #emailformData.Sold_to_Party#. You will receive automated
          updates via email when your submission changes status. <b>- Admin Team</b>
        <cfelseif status_update EQ 'Assigned'>
          Form Assigned by Admin Request ID: #emailformData.ID# for the following party #emailformData.Sold_to_Party# was
          assigned to Admin ID #emailformData.Admin_ID# on #DateFormat(Now())#, #TimeFormat(Now())#.   
          Below is their direct  contact information for any change requests or status updates. <b>- Admin Team</b>
        <cfelseif status_update EQ 'Returned'>
          Returned by Admin Form ID: #emailformData.ID# for the following party #emailformData.Sold_to_Party# was
          returned by Admin ID #emailformData.Admin_ID# on #DateFormat(Now())#, #TimeFormat(Now())#
          for the following reasons. Admin Notes: #emailformData.Admin_Notes#.
          <b>- Admin Team</b>
        <cfelseif status_update EQ 'Completed'>
          Form Completed Form ID: #emailformData.ID# for the following party #emailformData.Sold_to_Party# has been
          marked as COMPLETED on #DateFormat(Now())#, #TimeFormat(Now())#. The following Quote Number has been
          assigned to this form #emailformData.Quote_Num#.  The quote will be emailed to you.  If the Admin added any closing notes to the form they will appear below:
          #emailformData.Admin_Notes#
          <b>- RFQ Admin Team</b>
        </cfif>
      </cfmail>
    </cfoutput>
</cffunction>

您不需要它,除非您正在循环输出cfquery。例如,如果你的emailformData查询返回多行(它显然没有),你可以这样做:

<cfmail ...>
    Here's the email data #form.name# asked for:
    <cfoutput query="emailformData">
        #emailformData.Sold_to_Party#
    </cfoutput>
    Sent on #dateFormat(now())#
</cfmail>

请参阅Adobe网站上cfmail标记的示例使用,以及Ray Camden网站上的讨论

相关内容

  • 没有找到相关文章

最新更新