sending HTML email

G

Guest

I have a fairly large piece of html, about 50 lines that I would like to send
via an ASP.NET page I was wondering what would be the best and cleanest way
to do this? Is there a way I can put the code in a WebControl or text file
and pass that to Mailmessage.Body?

Any suggestions would be great.

Thanks, Justin.
 
G

Guest

Justin, it depends more on how you want to maintain the text (e.g. from a
text file, in the db, in a web control, etc.). All of these are doable. In a
text file, I'd go (vb):

public function GetMyText as string
Dim fi As New System.IO.FileInfo(Server.MapPath("~\myText.txt"))
Dim sr As System.IO.StreamReader = fi.OpenText()
return sr.ReadToEnd
end function

then... mailmessage.body = GetMyText()

If it's mostly static and you send a lot of them, you should also consider
caching the text at the app level.

hth,
Bill
 
G

Guest

Can you recommend an article or tutorial that will help me develop user
control that will hold the HTML? Or any other tutorials on sending HTML email
with asp.net.

Thanks, Justin.
 
G

Guest

Several good ones from Scott Mitchell:

http://aspnet.4guysfromrolla.com/articles/102203-1.aspx
http://www.4guysfromrolla.com/webtech/080801-1.shtml

Enjoy. As far as using a user control for what you're doing, I don't know
the details, but doesn't seem to me like that's your best choice--it's extra
complexity with no big bang. If you want to maintain the html externally, I'd
use a text or xml file, or maybe the database. If you'd prefer to have it
"baked in" somewhere, I'd just use a plain old constant string. Anyway, have
fun.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top