这是我的代码执行是成功的,但是我的邮箱就是收不到邮件
大家帮忙看看这段代码为什么我的邮箱就是收不到邮件
try
{
MailMessage aMessage = new MailMessage();
aMessage.From = FromTextBox.Text;
aMessage.To = ToTextBox.Text;
aMessage.Cc = CCTextBox.Text;
aMessage.Bcc = BCCTextBox.Text;
aMessage.Subject = SubjectTextBox.Text;
aMessage.Body = MessageTextBox.Text;
if (AttachmentTextBox.Text.Length > 0)
aMessage.Attachments.Add(new MailAttachment(AttachmentTextBox.Text, MailEncoding.Base64)); SmtpMail.Send(aMessage); MessageBox.Show("邮件发送成功!");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
string password="";
string name="";
string email="";
string alertError;
name=this.TextBox1.Text.Trim();
if(name=="")
{alertError="<script language=\"javascript\">alert(\"请输入用户名!\");</script>";
Response.Write(alertError);
return;
}
if(this.TextBox2.Text.Trim()=="")
{
alertError="<script language=\"javascript\">alert(\"请输入密码!\");</script>";
Response.Write(alertError);
return;
}
if(this.TextBox3.Text.Trim()=="")
{
alertError="<script language=\"javascript\">alert(\"请输入邮箱!\");</script>";
Response.Write(alertError);
return;
}
//connect data*/
string sqlInsert_logon="insert login(name,password,email) values (@name,@password,@email) ";
this.sqlCommand_logon = new SqlCommand(sqlInsert_logon, this.sqlConnection_logon);
//this.sqlCommand_logon.CommandType = CommandType.StoredProcedure;
this.sqlCommand_logon.Parameters.Add("@name",this.TextBox1.Text.Trim());
this.sqlCommand_logon.Parameters.Add("@password",this.TextBox2.Text.Trim());
this.sqlCommand_logon.Parameters.Add("@email",this.TextBox3.Text.Trim());
this.sqlConnection_logon.Open();
//dbRead=this.sqlCommand_logon.ExecuteReader();
this.sqlCommand_logon.ExecuteNonQuery();
this.sqlConnection_logon.Close();
//SendMailMailMessage mail=new MailMessage();
mail.To="[email protected]";//receive
//mail.To="[email protected]";mail.From="[email protected]";
mail.Subject="your password";
mail.Body="this is a test for mailsend";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");//basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", ""); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "");//set your password here//SmtpMail.SmtpServer="localhost";
SmtpMail.SmtpServer="smtp.163.com";//send;popo.163.com----receive
SmtpMail.Send(mail);
//提示框
string scriptString = "<script language=javascript>";
scriptString += "alert('注册成功!请注意查收邮件')";
scriptString += "</script>";
if(!this.IsStartupScriptRegistered("Startup"))
this.RegisterStartupScript("Startup", scriptString);
}