Link to home
Start Free TrialLog in
Avatar of Wayne Barron
Wayne BarronFlag for United States of America

asked on

ASP Classic - Load HTML Email Template and change values

Hello all;

I found the following
http://www.evagoras.com/2011/02/07/formatting-complex-asp-output-using-html-templates/
Which works rather well, but I seem to run into an issue, where not all the values get replaced.

Example
   strText = Replace(strText, "REPLACE_Name", strName)
   strText = Replace(strText, "REPLACE_Email", strEmail)

Open in new window


So, if I change the top one, to another word here, and in the HTML Template.
It will not update, and change.

I have restarted IIS, to see if maybe there was an issue there.
And nothing.

So.
Is there another way to do this, where I can change the template values with records from the database?
That will work better than this one?

By the way, the article in the link uses the old CDONTS
I use CDOSYS.

This is my Replace, that I am doing.
I have it marked on the ones that work and do not work.


Function ReadFile(filename)
  Dim objFSO
  Dim objTStream
  Dim strText
  Const ForReading = 1

  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objTStream = objFSO.OpenTextFile(Server.MapPath(filename), ForReading)
      strText = objTStream.ReadAll
    Set objTStream = Nothing
  Set objFSO = Nothing
  strText = Replace(strText, "REPLACE_url", theurl) ' >>>>>>Dosn't Works
  strText = Replace(strText, "REPLACE_siteName", siteName) ' >>>>>>Dosn't Works
  strText = Replace(strText, "REPLACE_Welcome", theMessage) ' >>>>>>Dosn't Works
  strText = Replace(strText, "REPLACE_Question", theQuestion) ' >>>>>>Works
  strText = Replace(strText, "REPLACE_Zone", theZone) ' >>>>>>Works
  strText = Replace(strText, "REPLACE_Comment", theComment) ' >>>>>>Works
  strText = Replace(strText, "REPLACE_ID", theID) ' >>>>>>Works
  strText = Replace(strText, "REPLACE_copyright", strCopyright) ' >>>>>>Dosn't Works
  ReadFile = strText
End Function

Open in new window

Here are some of the codes in the post.htm page, that do not work.
<img src="REPLACE_url/graph/business-mini.png" title="REPLACE_siteName" alt="REPLACE_siteName"/>
<div style ="padding-top: 0.3em;">REPLACE_Welcome</div>
 <a href="REPLACE_url">REPLACE_siteName</a>
 <span style="color:#FFF;">REPLACE_copyright</span>

Open in new window


Thanks.
Carrzkiss
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wayne Barron

ASKER

Thanks, Ryan.
Adding in the response.write can be to looking around, and I was able to find the cause of the issue.
Have a rockin rest of the weekend.

Wayne