string mailTo = "******@126.com";
string smtpServer = "smtp.163.com";
string mailFrom = "*****@163.com";
string userPassword = "密码";
//邮件服务设置
SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Host = smtpServer;
smtpClient.Credentials = new System.Net.NetworkCredential(mailFrom, userPassword);
//发送邮件设置
MailMessage mailMessage = new MailMessage(mailFrom, mailTo);
mailMessage.Subject="邮件服务测试";
mailMessage.Body = "现在是邮件服务发来的测试邮件;<a href=\"http://www.baidu.com\">百度首页</a>";
mailMessage.BodyEncoding=Encoding.UTF8;
mailMessage.IsBodyHtml=true;
mailMessage.Priority=MailPriority.Low;//优先级
try
{
smtpClient.Send(mailMessage);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
string smtpServer = "smtp.163.com";
string mailFrom = "*****@163.com";
string userPassword = "密码";
//邮件服务设置
SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Host = smtpServer;
smtpClient.Credentials = new System.Net.NetworkCredential(mailFrom, userPassword);
//发送邮件设置
MailMessage mailMessage = new MailMessage(mailFrom, mailTo);
mailMessage.Subject="邮件服务测试";
mailMessage.Body = "现在是邮件服务发来的测试邮件;<a href=\"http://www.baidu.com\">百度首页</a>";
mailMessage.BodyEncoding=Encoding.UTF8;
mailMessage.IsBodyHtml=true;
mailMessage.Priority=MailPriority.Low;//优先级
try
{
smtpClient.Send(mailMessage);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}