asp.net2.0发送邮件
asp.net2.0中使用System.Net.Mail中的类来发送邮件 只支持SMTP简单邮件传输
发件人邮件地址只能用支持SMTP的邮件服务器发送
发送邮件代码如下:
发件人邮件地址只能用支持SMTP的邮件服务器发送
发送邮件代码如下:
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage("zxbiao20050917@163.com","woshiwopengpeng@yahoo.com.cn");
mail.Body = "hahahahahahah";
mail.Priority =System.Net.Mail.MailPriority.High;
mail.Subject = "test";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.163.com";
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
//smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("用户名", "密码");
smtp.Timeout = 10000;
smtp.Send(mail);
mail.Body = "hahahahahahah";
mail.Priority =System.Net.Mail.MailPriority.High;
mail.Subject = "test";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.163.com";
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
//smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("用户名", "密码");
smtp.Timeout = 10000;
smtp.Send(mail);