使用.net 自带的using System.Web.Mail;来发邮件。
private void SendMail()
{
try
{
MailMessage mail=new MailMessage();
mail.From = "<liulurong@163.com>";
mail.To = "shaofei8989@163.com";
mail.Subject = "这是一个病毒!";
mail.Body="你死定了。HOHOOHHOHOOOOO";
mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
mail.BodyFormat = MailFormat.Text;
mail.Priority = MailPriority.High;

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "MaxMan"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); //set your password here
//这个的smtp服务器要写正确。都是以smtp开头的。
SmtpMail.SmtpServer = "smtp.163.com"; //your real server goes here

SmtpMail.Send( mail );
}
catch(Exception ex)
{
throw ex;
}
}
private void SendMail()
{
try
{
MailMessage mail=new MailMessage();
mail.From = "<liulurong@163.com>";
mail.To = "shaofei8989@163.com";
mail.Subject = "这是一个病毒!";
mail.Body="你死定了。HOHOOHHOHOOOOO";
mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
mail.BodyFormat = MailFormat.Text;
mail.Priority = MailPriority.High;
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "MaxMan"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); //set your password here
//这个的smtp服务器要写正确。都是以smtp开头的。
SmtpMail.SmtpServer = "smtp.163.com"; //your real server goes here 
SmtpMail.Send( mail );
}
catch(Exception ex)
{
throw ex;
}
}

浙公网安备 33010602011771号