473,486 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sending HTML email

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.
Nov 18 '05 #1
4 1588
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

"Justin" wrote:
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.

Nov 18 '05 #2
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.

"Bill Borg" wrote:
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

"Justin" wrote:
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.

Nov 18 '05 #3
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

"Justin" wrote:
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.

"Bill Borg" wrote:
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

"Justin" wrote:
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.

Nov 18 '05 #4
Justin,
Or any other tutorials on sending HTML email
with asp.net.


I've recently posted a little helper library to manage email templats at
CodeProject

http://www.codeproject.com/csharp/mailtemplates.asp

Hope it comes handy :-)
Philipp
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2950
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
2
1738
by: Paul Turley | last post by:
Does anyone have some sample code for sending an HTML formatted message using CDONTS? Thanks RE: Sending HTML formatted mail using CDONTS -- Paul Turley, MCSD, MCAD, MCT, MSF...
6
2392
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
6
2711
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
4
5030
by: Roger Withnell | last post by:
I'm sending Russian text in an email generated from the website which displays in the email as ?????????? The website is set to codepage 65001 and the charset to utf-8. Please advise. ...
7
4372
by: Ray Booysen | last post by:
Hi all I'm sending email via ASP.NET in HTML mode. Each email has exactly one attachment and I do have full access to the SMTP server. However, if I send the email in HTML format, the...
1
2924
by: robbiesmith79 | last post by:
Just so this is out there on the web, I battled the past 24 hours about this. Background info... I developed a ecommerce website in PHP 4 on a shared linux hosting plan from GoDaddy and had the...
2
4658
by: Aneesh Pulukkul[MCSD.Net] | last post by:
Hi, I have a HTML page and associated images. I need to send the HTML as email -the email should also display the images at respective places. So am sending the content of HTML file as...
7
9737
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
1
1780
by: runway27 | last post by:
<?php $headers = "Content-type: text/html; charset=iso-8859-1"; $to="myemailaddress"; $subject="Email Newsletter"; $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
7094
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6839
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3066
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.