.net邮件发送[c#]
时间:2011-04-13 来源:zhxhdean
using System.Web.Util; using System.Net.Mail;有兴趣的朋友,可以将发送封装成方法,方便其他调用。
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(目标邮箱);
mailMessage.From = new System.Net.Mail.MailAddress(发送邮箱);
mailMessage.Subject = 邮件主题;
mailMessage.Body = 邮件内容;
mailMessage.IsBodyHtml = true;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.Priority = System.Net.Mail.MailPriority.Normal;
SmtpClient() smtpClient = new SmtpClient();
smtpClient.Credentials = new System.Net.NetworkCredential("发送邮箱", "发送邮箱密码");
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Host = "邮件服务器";
smtpClient.Send(mailMessage);
相关阅读 更多 +