Skip to main content
Inspiring
August 28, 2006
Question

Variable inside a variable

  • August 28, 2006
  • 2 replies
  • 344 views
Hi all,

I am building a mailer to allow a client to copy and paste their html email data into a form field and allow them to mail merge the data to their client database. The email should be sent to all records of the users table and should include the users name in the body of the email.

I almost have it working perfectly, but my problem lies in the variable name for the users name being included in the pasted html instead of the value of the variable.

The process is as follows:
1. The administrator copies and pastes their html into a form page
2. The administrator adds the relevant variable to the text of the email, in this case, #firstName#
3. The administrator hits submit and the form is posted to a page that loops through all records on the user tables and sends the email to each of the addresses and *should* include the user name in the email text

The problem is that if the administrator enters
"Dear #firstName#," into the html form, the email will actually display #firstName# as text.

Can anyone offer any advice on how to get my cfmail inside a cfloop to replace #firstName# with the value of the first name.

TIA<
Paul
    This topic has been closed for replies.

    2 replies

    Participating Frequently
    August 28, 2006
    See the Evaluate function.

    It should be able to dynamically evaluate the string data submitted by the form as CFML. If you run into problems, you can also try the DE (delay evaluation) function in combination with the Evaluate function.

    Example:
    <cfset messageTxt=evaluate(de(messageTxt))>
    BKBK
    Community Expert
    Community Expert
    August 28, 2006
    Coldfusion regards what the form submits, #firstName#, as string data, not as CFML code. It therefore cannot execute it. In fact, if it could, then you would have had to submit the text <cfoutput>#firstName#</cfoutput>. However, Coldfusion would ignore even that, too. If you want to include first names dynamically, you should include "Dear #firstName#," among the code in the cfmail tag.