January 2nd, 2013, 08:34 AM
storing text in a DB for use in an email that parses variables when used
Apologies if the title is a bit difficult to understand, but I wasn't sure what else to put.
heres, my issue...I have several pages in my site that send emails...a couple of these pages send what is effectively the same email and use something like
then, as each record loops round, the email is built the with variables pulled from the database to replace the name etc.
get first recipient
email_contents = "Hello " & rs1.Fields.Item("username").Value & "<br><br>"
email_contents = email_contents & "Please be aware that the " & rs1.Fields.Item("eventname").Value & " is going to be cancelled"
loop round to get next recipient
The issue is that if I want to change the contents of the email, I have to edit the file itself. I would rather have this stored in a DB and then it would be easier to change, and for places where the same email is used I could just call the particular email from the database and wouldn't have to edit it in two places if I wanted to change it.
The problem I have, is how can I store the contents I want AND have the correct variables parsed as the email is sent? what happens of course is that the email is sent with the 'variables' as text so the person receives an email with code in it, because it isn't recognised as script and therefore parsed with the correct variables in it. I need to know how to escape the code so that it gets parsed correctly when the email is sent.
thanks in advance
January 3rd, 2013, 08:12 AM
the easy way to do that is insert custom tags in your email something like in database you need to have
"Hello <username><br><br>Please be aware that the <eventname>is going to be cancelled"
after you read this in variable
strBody you need to run for each record
strBodyT= replace(strBodyT,<username>, rs1("username'))
strBodyT= replace(strBodyT,<eventname>, rs1("eventname'))
if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
January 4th, 2013, 03:22 AM
I figured that was what I was going to have to do...thanks for confirming.