//发送邮件服务器
SmtpClient client = new SmtpClient();
client.Host = "mail.cpp114.com"; //指定邮件服务器
client.Credentials = new NetworkCredential("zgdx0503@cpp114.com", "123456");//指定服务器邮件,及密码
//发送
try
{
client.Send(oMail); //发送邮件
Label1.Text = "恭喜你!邮件发送成功。";
}
catch
{
Label1.Text = "邮件发送失败,检查网络及信箱是否可用。";
}
oMail.Dispose(); //释放资源
TABLE1.Visible = false;
Table2.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
//返回,继续发送
Response.Redirect(Request.Url.ToString());
TABLE1.Visible = true;
Table2.Visible = false;
}
}
3、运行并输入测试信箱zgdx0503@tom.com,(密码:123456)。如下所示:

4、打开信箱查看








