Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Mail - works with 1.1 but not 2.0 framework

Status
Not open for further replies.

MattSTech

Programmer
Apr 10, 2003
333
US
I have a page that uses SMTP to send mail. My host upgraded from .NET 2.0 from 1.1 and both pages of ASP code no longer work. This has to be a simple thing, but I just don't get what needs to change. Any thoughts?

Code:
                                <p> 
                                  <%@ Page Language="C#" %>
                                  <%@ Import NameSpace="System.Web.Mail" %>
                                  <script runat="server">
	protected void Page_Load(Object Sender, EventArgs e) {
		if(!Page.IsPostBack)
			Message.Text = "";
	}
	protected void Send_Email(Object Sender, EventArgs e) {
		MailMessage mail = new MailMessage();
			mail.To = "info@sitenamegoeshere.com";
			mail.From = Request.Form["from"];
			mail.Subject = "Web Email Form";
			mail.Body = Request.Form["body"];
		SmtpMail.SmtpServer = "smtp.myisp.com";
		SmtpMail.Send(mail);
		Response.Flush();

		Message.Text = "Message Sent...<br><br>" + 
				"<a href=\"contacts.aspx\">Go Back</a>";
	}
</script>
 
the namespace changed from System.Web.Mail to System.Net.Mail. that's at least one reason.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top