1 Reply Latest reply on Jun 15, 2006 12:00 PM by reya276

    Newsletter Templates

    reya276
      I have created a newsletter template which resides in a database table, now within this newsletter I want to do a query ouput, since I know I can't nest cfoutput tags I created cfloops and call the queries but this is not work. My goal is for the users to create their own newsletter templates without having to insert the content but instead populate the content from the database any help anyone can offer with be greatly appreciated.
        • 1. Re: Newsletter Templates
          reya276 Level 1
          OK I figured out the answer. You first do a cffile function to write the contents of the template from the database, then with your cfmail call you do a cfinclude for the file you just wrote. This way you can do any types of cfloops and cfoutputs you want without a worry or copromising any type of security. Then after your cfmail call you do a cffile action="detele" to remove the file from the directory and you are done.

          <cfset filePath = #GetDirectoryFromPath(ExpandPath("."))#&"cms\newsletter_files\"&#sendnews.temp_name#&".tx t">
          <cffile action="write" file="#filePath#" output="#sendnews.temp_copy#" />
          <cfmail to="test@123.com" from="test@test.com" Subject="test email" replyto="test@test.com" type="html" spoolenable="yes">
          <cfinclude template="newsletter_files/#sendnews.temp_name#.txt">
          </cfmail>
          <cffile action="delete" file="#filePath#">