一般是第一次成功 第2次就失败...
public static void SendMail(string from, string to, string subject, string body)
{
SmtpClient mailClient = new SmtpClient();
mailClient.Credentials = new System.Net.NetworkCredential("...", "...");
mailClient.Host = "smtp.sina.com";
MailMessage mailMessage = new MailMessage(from, to, subject, body);
mailClient.Send(mailMessage);
}
public static void LogError(Exception ex)
{
string dateTime = DateTime.Now.ToString();
string errorMessage = "异常发生在: " + dateTime;
System.Web.HttpContext context = System.Web.HttpContext.Current;
errorMessage = "略...";
string from = "[email protected]";
string to = "[email protected]";
string subject ="错误信息";
string body = errorMessage;
SendMail(from, to, subject, body);
}
public static void SendMail(string from, string to, string subject, string body)
{
SmtpClient mailClient = new SmtpClient();
mailClient.Credentials = new System.Net.NetworkCredential("...", "...");
mailClient.Host = "smtp.sina.com";
MailMessage mailMessage = new MailMessage(from, to, subject, body);
mailClient.Send(mailMessage);
}
public static void LogError(Exception ex)
{
string dateTime = DateTime.Now.ToString();
string errorMessage = "异常发生在: " + dateTime;
System.Web.HttpContext context = System.Web.HttpContext.Current;
errorMessage = "略...";
string from = "[email protected]";
string to = "[email protected]";
string subject ="错误信息";
string body = errorMessage;
SendMail(from, to, subject, body);
}
解决方案 »
- asp.net面包屑导航和下载的问题!(急)
- jquery ui dialog 问题(添加到form1里面后还是无法使用服务器控件)
- 关于Repeater控件的问题
- 未能加载类型 Fredck.Fckeditorv2
- 上传文件的一个问题
- 用DataGrid分页的问题,在线等待!!!!马上结贴!!!!
- 请问我错在哪里呀!
- ascx里的控件怎么访问阿?
- ASP.net 中 ,利用OWC生成条形柱状图报表之后,如何在条形图报表上的一个小条形区域做点击事件响应?
- 谁做过公路收费打印程序,用户要求速度不能超过五秒!可我在2000下7秒
- 用过expression web 的大侠请进来!!
- 大家帮帮忙,关于拼音索引,有思路者就有分
有两个参数第一个为用户名,第二个为密码。
mailClient.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
mailClient.Host = "smtp.mail.yahoo.com";
MailMessage mailMessage = new MailMessage("[email protected]", "[email protected]", "主题", "内容");
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
try
{
mailClient.Send(mailMessage);
Response.Write("Email successfully send.");
}
catch (Exception ex)
{
Response.Write("Send Email Failed." + ex.ToString());
}