public void sendEmail(string email)
{
string smtp = "smtp.163.com";
string mailForm = 发送人帐号;
string mailPwd = 发送人密码;
string mailTo = email;//接收人邮箱帐号
string mailTitle = "邮件标题";
string mailContent = 邮件内容;
SmtpClient client = new SmtpClient(smtp);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(mailForm, mailPwd);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage message = new MailMessage(mailForm, mailTo, mailTitle, mailContent);
message.BodyEncoding = Encoding.Default;
message.IsBodyHtml = true;
client.Send(message);
}
试试这段代码。
虽然已经自己解决了。。
实现的方式跟你这段代码大致相同。。
catch一下什么异常呢