Skip to main content
January 28, 2009
Question

Dynamic Email Message

  • January 28, 2009
  • 2 replies
  • 544 views
Hey guys,
I am trying to write a small email tool that is basically a mail merge. The user types what they want, tell it what table they want it to pull user information from and it goes. however, I want the email they write to be able to use information found in the table to they specify. So if the query that pulled the info was called "UserInfo" and it had a field called firstname, I would like the user to be able to type in the box

Hello #firstname#,
blah blah blah.

and the message would be evauluated for each email that gets sent out. Right now when I type that into the textbox, and echo it out, it simple says

Hello #firstname#,

instead of actually parsing the value of firstname. How can I force it to parse the values of things in # #? I tried using evaluate on the whole message, but of course that doesnt work. Keep in mind I am using the richtext editor.

Attached is my code so far.
This topic has been closed for replies.

2 replies

Inspiring
January 29, 2009
<cfsavecontent variable="session.x">
cold fusion and html code goes here
</cfsavecontent>

<cfoutput>#session.x#</cfoutput>

Also bear in mind that cfmail is in some ways equivalent to cfoutput.
January 29, 2009
Thanks for the tip, Ill try and write something real quick and see how it goes. I'll let ya know how it turns out.
January 29, 2009
Dan,
Well I tried. Sadly I'm just having a hard time wrapping my brain around this. I know its not hard, but I'm just not comprehending.

Here is a link to the demo app
http://www.digitalswordsmen.com/dynamicformtest.cfm

And attached is my code. I tried with and without CFOUTPUT around the SAVECONTENT but it didn't work either way. I just wrote a super simple demo app. Basically you should be able to enter #Firstname# in there, and it will then evaluate that when it outputs it to the screen, but it does not.

As a side note, if the info didn't have to come from a form box, your original idea works beutifully. You can type text and variables in there, and it does exactly what you would expect it to do. However, when you feed the form variable into there, it does not parse the variables, inside of the variable. It gets passed #form.Myletter# and it just slaps that in there, it doesn't look inside #form.Myletter# to see if there is anything in there that needs evaluation. I really have no idea how to get around that.
Inspiring
January 28, 2009
For the view, then send part, think about what you can do with cfsavecontent in the session scope.

For the selection of tables and fields, you are asking for trouble if you want the users to type these. Maybe related selects are a better option.
January 28, 2009
Dan,
Good though about it being a bad idea having the type that in. I think there is a table that has all the ID's that would be valid for that box, so I can probably just turn that into a drop down.

I hate to sound like a leech here, but could you maybe provide a bit of sample code for what you are thinking about with the sessions and the savecontent? I just don't follow your train of thought. Thanks for your help so far, I really appreciate it.