/** <summary>
/// 注册时发送用户帐号跟密码
/// </summary>
/// <param name="receiver">用户注册邮箱</param>
/// <param name="username">用户名</param>
/// <param name="password">用户密码明文</param>
public bool Register(string receiver, string username, string password)
...{
//System.Net.Mail.SmtpClient mail = new System.Net.Mail.SmtpClient();
//邮件发送时请确认服务的杀毒软件因素
System.Net.Mail.SmtpClient client;
client = new System.Net.Mail.SmtpClient("smtp.163.com");
client.Timeout = 60000;
//client.UseDefaultCredentials = false;
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("abc@163.com", "123456");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.From = new System.Net.Mail.MailAddress("abc@163.com", "Andy Lu", System.Text.Encoding.UTF8);
message.To.Add(new System.Net.Mail.MailAddress(receiver, username, System.Text.Encoding.UTF8));
message.IsBodyHtml = false;
message.Subject = "用户注册信息(软件项目网)";
message.Body = username + ":您好! 欢迎您光临软件项目网[http://www.softprj.cn]!您注册的用户名是:" + username + ";密码是:" + password + "。 点此进入软件项目网:http://www.soft.cn";
try
...{
client.Send(message);
return true;
}
catch
...{
return false;
}
}
看了无数篇,检查了N次,原来是VirusScan 惹得祸!
关掉其“按访问扫描”一切OK
参考此篇http://blog.csdn.net/mengyao/archive/2007/08/16/1745836.aspx
转自:http://blog.csdn.net/mengyao/archive/2007/08/15/1743427.aspx