广州解放军男性医院:有知道用ASP.net发邮件的吗?帮我看看这个是怎么错了

来源:百度文库 编辑:查人人中国名人网 时间:2024/03/29 03:16:14
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Web.UI.WebControls" %>
<%@Import Namespace="System.Web.Util" %>
<%@Import Namespace="System.Web.Mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<HTML>
<HEAD>
<title>Washington Debt Consolidation - Free Quotation</title>
<script runat="server">
void Button_Click(Object sender, EventArgs e){

// OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=simple.mdb;");

// OleDbCommand myCommand;
string dateTime = DateTime.Now.ToString();

MailMessage mailObj = new MailMessage();
mailObj.From = "info@wdcfinancial.com";
mailObj.To= "oonny@126.com";
mailObj.Subject = "Online Quite";
mailObj.Body = "Request support received on " + dateTime + "\n\n"
+ "First Name: " + firstname.Text.ToString() + "\n"
+ "Last Name: " + lastname.Text.ToString() + "\n"
+ "Address:" + addresss.Text.ToString() + "\n"
+ "State:" + state.Value.ToString() + "\n"
+ "zip:" + zip.Text.ToString() + "\n"
+ "E-mail:" + email.Text.ToString() + "\n"
+ "Home Phone:" + homephone.Text.ToString() + "\n"
+ "Work Phone:" + workphone.Text.ToString() + "\n"
+ "Cell Phone:" + cellphone.Text.ToString() + "\n"
+ "Best time to contact you:" + TimeToCall.value.ToString() + "\n"
+ "Extension:" + extension.Text.ToString() + "\n"
+ "Fax" + fax.Text.ToString() + "\n";

// myCommand = new OleDbCommand("INSERT INTO Contact(Name, Company, Email, Phone, Summary, Contacts, EnterTime) VALUES ('"
// + nameID.Text + "', '" + companyID.Text + "', '" + emailID.Text + "', '" + phoneID.Text + "','" + summaryID.Text
// + "', '" + contactMethodID.Text + "', '" + dateTime + "')", myConnection);
// myConnection.Open();
// myCommand.ExecuteNonQuery();
// myConnection.Close();
mailObj.To = "info@wdcfinancial.com";
SmtpMail.SmtpServer="66.40.38.125";
SmtpMail.Send(mailObj);
Response.Redirect ("EmailSimple.aspx");

}
</script>

底下的控件都是WEB控件,可是上传到服务器之后还是无法显示,浏览器说:
Server Error in '/' Application.

Runtime Error
……

(写不下,开头两行是这样的)
求高手指点指点,急用!!!!

我没有做过发邮件的,不过我帮你回了下,你大概看下人家的回复

1:

如果在验证的话。
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
// mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","username");
// mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","password");
//

2:
如果 不验证,就去掉 SmtpMail.SmtpServer="66.40.38.125";