1. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    May 2004
    Rep Power

    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

    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"
    send email
    loop round to get next recipient
    then, as each record loops round, the email is built the with variables pulled from the database to replace the name etc.

    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
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Columbus, OH
    Rep Power
    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
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    May 2004
    Rep Power
    I figured that was what I was going to have to do...thanks for confirming.

Similar Threads

  1. Storing variables back to DB
    By Scooty in forum ASP Development
    Replies: 2
    Last Post: March 9th, 2005, 10:16 PM
  2. storing variables
    By deongee in forum ASP Development
    Replies: 3
    Last Post: December 24th, 2004, 08:59 PM
  3. Storing ASP variables in javascript
    By swaytze in forum .NET Development
    Replies: 2
    Last Post: August 25th, 2004, 09:33 AM
  4. Storing Variables From Checkboxes
    By paradox in forum ASP Development
    Replies: 2
    Last Post: May 18th, 2004, 03:30 PM
  5. Reading text file and storing data into variables..
    By rico in forum .NET Development
    Replies: 1
    Last Post: March 1st, 2004, 03:55 AM

IMN logo majestic logo threadwatch logo seochat tools logo