C#.Net发送邮件帮助类 

带发送人昵称帮助类库下载



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Net.Mail;
using System.Net;
using System.Text;
 
namespace Web.AppCode
{
    public class MailMgr
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="to">接收人</param>
        /// <param name="subject">主题</param>
        /// <param name="content">邮件内容</param>
        public void SendEmail(string to,string subject,string content)
        {
 
            string MailFrom = ConfigurationManager.AppSettings["emailUser"];
            string MailFromPassword = ConfigurationManager.AppSettings["emailPwd"];
            string MailServer = ConfigurationManager.AppSettings["emailService"];
            SmtpClient smtp = new SmtpClient(); //实例化一个SmtpClient
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network; //将smtp的出站方式设为 Network
            smtp.EnableSsl = false;//smtp服务器是否启用SSL加密
            smtp.Host = MailServer; //指定 smtp 服务器地址
            smtp.Port = 25;
            smtp.UseDefaultCredentials = true;
             
            smtp.Credentials = new NetworkCredential(MailFrom, MailFromPassword);
 
            MailAddress mAddress = new MailAddress (MailFrom,"yunjson.com");    
 
 
            MailMessage mm = new MailMessage(); //实例化一个邮件类
            mm.Priority = MailPriority.Normal;
           // mm.From = new MailAddress(MailFrom);
            mm.From = mAddress;
            mm.To.Add(to);
            mm.Subject = subject;
            mm.SubjectEncoding = Encoding.GetEncoding(936);
            mm.IsBodyHtml = true;
            mm.BodyEncoding = Encoding.GetEncoding(936);
            mm.Body = content;
            smtp.Send(mm);
        }
 
    }
}