c#发送邮件
public static void SendEmail()
{
try
{
if (DateTime.Now.Day % 2 == 0)
{
//实例化SmtpClient
SmtpClient client = new SmtpClient("smtp.126.com", 25);
//出站方式设置为NetWork
client.DeliveryMethod = SmtpDeliveryMethod.Network;
//smtp服务器验证并制定账号密码
client.Credentials = new NetworkCredential("xxx@126.com", "123456");
MailMessage message = new MailMessage();
//设置优先级
message.Priority = MailPriority.Normal;
//设置收件方看到的邮件来源为:发送方邮件地址、来源标题、编码
message.From = new MailAddress("xxx@126.com", "2222", Encoding.GetEncoding("gb2312"));
//接收方
message.To.Add("dddddd@163.com");
//标题
message.Subject = "标题";
message.SubjectEncoding = Encoding.GetEncoding("gb2312");
//邮件正文是否支持HTML
message.IsBodyHtml = true;
//正文编码
message.BodyEncoding = Encoding.GetEncoding("gb2312");
string ip = new Regex(@"您的IP地址是:\[([\d.]+?)\]").Match
(new WebClient().DownloadString("http://www.ip138.com/ip2city.asp")).Groups[1].Value;
client.Send("<font color='red'>测试</font><br/>");
}
}
catch (Exception e)
{
}
}
code in my life.
摘自 ghypnus
补充:软件开发 , C# ,