I wrote a function which reads it ok. (See below)
The only probelm is that the HTML shows up in the email message with the raw
code, even though I set IsBodyHtml to true. Any ideas?
Here's the code to read the html...
Private Function ReadHtmlPage(ByVal url As String) As String
Dim file As String = Server.MapPath(url)
Dim sr As System.IO.StreamReader
Dim fi As New System.IO.FileInfo(file)
Dim strContents As String = ""
If System.IO.File.Exists(file) Then
sr = System.IO.File.OpenText(file)
strContents += Server.HtmlEncode(sr.ReadToEnd())
sr.Close()
End If
Return strContents
End Function
> If the HTML file is located on your server, just read it as ordinary text
> file and perform string.Replace() on the placeholders
[quoted text clipped - 4 lines]
>>I have an HTML file that I want to read on the fly and insert the contents
>>into a string (for the body of an email.) How can I do this?
Lau Lei Cheong - 20 Feb 2006 04:56 GMT
If you can see the raw code, then the "read" part should be OK.
I believe you should post the "send" code in order for us to find out what's
wrong.
"VB Programmer" <dont@emailme.com> ¼¶¼g©ó¶l¥ó·s»D:eo$$GacNGHA.740@TK2MSFTNGP12.phx.gbl...
>I wrote a function which reads it ok. (See below)
>
[quoted text clipped - 34 lines]
>>>I have an HTML file that I want to read on the fly and insert the
>>>contents into a string (for the body of an email.) How can I do this?
Russell - 20 Feb 2006 14:15 GMT
Try changing
strContents += Server.HtmlEncode(sr.ReadToEnd())
to
strContents += sr.ReadToEnd()
You are actually destroying your tags at that point because the HTML
encoding converts '<' to "<", '>' to ">", etc, which then appear
as literal characters in your email.
> I wrote a function which reads it ok. (See below)
>
[quoted text clipped - 35 lines]
> >>I have an HTML file that I want to read on the fly and insert the contents
> >>into a string (for the body of an email.) How can I do this?
VB Programmer - 20 Feb 2006 18:32 GMT
Bingo! Thanks alot Russell (and everyone else!!)
Try changing
strContents += Server.HtmlEncode(sr.ReadToEnd())
to
strContents += sr.ReadToEnd()
You are actually destroying your tags at that point because the HTML
encoding converts '<' to "<", '>' to ">", etc, which then appear
as literal characters in your email.
VB Programmer wrote:
> I wrote a function which reads it ok. (See below)
>
[quoted text clipped - 38 lines]
> >>contents
> >>into a string (for the body of an email.) How can I do this?