Sending Email with HTML body

G

Guest

Hi,
Is there a simple way to send an email from ASP.NET using the MailMessage
class with MyMessage.BodyFormat = MailFormat.Html, such that the body of the
email will come from an existing HTML file?

All the examples I was able to find have something like this:
string strBody = "<html><body><b>Hello World</b>" +
" <font color=\"red\">ASP.NET</font></body></html>";
MyMessage.Body = strBody;

But I want the content to come directly from an existing HTML file.
Thanks in advance.
 
K

Karl Seguin [MVP]

If this is a pure .html file, you can simply open it via the StreamReader.

dim sr as StreamReader
try
sr = new StreamReader("myFile.html")
dim content as string = sr.ReadToEnd()
MyMessage.Body = content
finally
if not sr is nothing then
sr.close()
end if
end try
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top