日期:2014-05-18 浏览次数:21627 次
string myMailEncoding = "BIG5"; string myFromEmail = "ifitch@sina.com"; string myFromName = "狗走猫步"; string myToEmail = "ifitch@sina.com"; string myToName = "扯把子打灰机"; MailAddress from = new MailAddress(myFromEmail, myFromName, Encoding.GetEncoding(myMailEncoding)); MailAddress to = new MailAddress(myToEmail, myToName, Encoding.GetEncoding(myMailEncoding)); MailMessage myMessage = new MailMessage(from, to); myMessage.Subject = "狗走猫步-扯把子打灰机"; myMessage.SubjectEncoding = Encoding.GetEncoding(myMailEncoding); myMessage.Body = "<h1>1v5这是邮件内容</h1>"; myMessage.BodyEncoding = Encoding.GetEncoding(myMailEncoding); myMessage.IsBodyHtml = true; myMessage.Priority = MailPriority.High; SmtpClient smtp = new SmtpClient("smtp.sina.com"); smtp.UseDefaultCredentials = false; smtp.Credentials=new NetworkCredential(myFromEmail, "密码"); try { smtp.Send(myMessage); Response.Write("寄信成功"); } catch { Response.Write("寄信失败"); }