I am using System.IO.FIle.ReadAllText() to get the contents of some template files that I created for email content. Then I want to do a Replace on certain tokens within the files so I can add dynamic content to the template.
Here is the code I have, it seems to me like it should work just fine...
Dim confirmUrl As String = Request.ApplicationPath & "?v=" & reg.AuthKey
Dim text As String = IO.File.ReadAllText( _
ConfigurationManager.AppSettings("sign_up_confirm_email_text").Replace("~", _
Request.PhysicalApplicationPath))
Dim html As String = IO.File.ReadAllText( _
ConfigurationManager.AppSettings("sign_up_confirm_email_html").Replace("~", _
Request.PhysicalApplicationPath))
text.Replace("%%LINK%%", confirmUrl)
text.Replace("%%NAME%%", person.fname)
html.Replace("%%LINK%%", confirmUrl)
html.Replace("%%NAME%%", person.fname)
For some reason I cannot get the %%LINK%% and %%NAME%% Replace() calls to work properly. I checked to see if it was encoding-related, so I made each file UTF-8. And also used the forced encoding overload of ReadAllText(String, Encoding) and still no dice. Any ideas?