Okay, much thanks to Bob Krieger on this one. He came over and gave me a hand. Below is the code as it sounds now. I origionally wrote the code without looping over a list. When I added the loop, I had a couple of problems. The biggest problem was that I was not setting the variables in the list dynamicaly. I still had the one line set up for only one variable. Sometimes, it just takes a fresh set of eyes! Thanks again Bob!
Brian M Falls <cfset viewcurrent = "http://intra-prod/ctfa/#request.self#?fuseaction=#xfa.viewcurrent#"> <cfquery name="loopgen" datasource="#request.dsn#"> SELECT CorrespondingField FROM dbo.emailcontent </cfquery> <cfset emaillist = ""> <cfoutput> <cfloop collection="#attributes#" item="i"> <cfif isdate(evaluate("attributes.#i#")) and i neq "publicationdate"> <cfloop query="loopgen"> <cfif i eq correspondingfield> <cfif isdate(evaluate("attributes.#i#"))> <cfset emaillist = listappend(emaillist, i, "|")> </cfif> </cfif> </cfloop> </cfif> </cfloop> </cfoutput> <cfloop list="#emaillist#" index="i" delimiters="|"> <cfquery name="mailer" datasource="#request.dsn#"> SELECT emailto, emailfrom, emailcc, emailsubject, emailmessagetext, emailattachment FROM emailcontent WHERE CorrespondingField = '#i#' </cfquery> <cfoutput query="mailer"> <!--- Setting email subject. ---> <cfset FoundPound = False> <cfset VariableName = ""> <cfset VariableArray = ArrayNew(2)> <cfset VariableNameCounter = 1> <cfloop list="emailsubject|emailmessagetext|emailattachment" index="switchhitter" delimiters="|"> <cfloop from="1" to="#Len(evaluate('mailer.#switchhitter#'))#" index="FoundAtPosition"> <cfset TheLetter = Mid(evaluate("Mailer.#switchhitter#"), FoundAtPosition, 1)> <cfif TheLetter EQ "##" and FoundPound EQ False> <cfset FoundPound = True> <cfelseif TheLetter EQ "##" and FoundPound EQ True and Trim(VariableName) NEQ ""> <cfset VariableArray[VariableNameCounter][1] = Replace(VariableName, "##", "")> <cfset TempVariableName = VariableArray[VariableNameCounter][1]> <cfset VariableArray[VariableNameCounter][2] = "#Evaluate('#TempVariableName#')#"> <cfset VariableNameCounter = VariableNameCounter + 1> <cfset VariableName = ""> <cfset FoundPound = False> <cfelseif FoundPound EQ True> <cfset VariableName = VariableName & "#TheLetter#"> </cfif> </cfloop> <cfif trim(mailer.emailfrom) neq ""> <cfset Variables.EmailFrom = mailer.emailfrom> </cfif> <cfset VariableNameCounter = VariableNameCounter - 1> <cfset "Variables.#switchhitter#" = evaluate("mailer.#switchhitter#")> <cfloop from="1" to="#VariableNameCounter#" index="LoopCounter"> <cfset "Variables.#switchhitter#" = ReplaceNoCase(evaluate("Variables.#switchhitter#"), "#VariableArray[Loopcounter][1]#", "#VariableArray[LoopCounter][2]#")> </cfloop> <cfset "Variables.#switchhitter#" = Replace(evaluate("Variables.#switchhitter#"), "##", "", "ALL")> </cfloop> </cfoutput> <cfmail to="[EMAIL PROTECTED]" from="#mailer.emailfrom#" subject="#Variables.emailsubject#" type="HTML" cc="">#Variables.emailmessagetext#</cfmail> </cfloop> ==^================================================================ This email was sent to: [email protected] EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrFMa.bV0Kx9 Or send an email to: [EMAIL PROTECTED] T O P I C A -- Register now to manage your mail! http://www.topica.com/partner/tag02/register ==^================================================================
