日期:2014-05-18 浏览次数:20464 次
using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Net.Mail; using System.Text; using System.Net; /// <summary> ///SendMail 的摘要说明 /// </summary> public class SendMail { private string _mailStmp; public string MailStmp { get { return _mailStmp; } set { _mailStmp = value; } } private string _mailFrom; public string MailFrom { get { return _mailFrom; } set { _mailFrom = value; } } private string _mailPwd; public string MailPwd { get { return _mailPwd; } set { _mailPwd = value; } } private string _mailTo; public string MailTo { get { return _mailTo; } set { _mailTo = value; } } private string _mailTitle; public string MailTitle { get { return _mailTitle; } set { _mailTitle = value; } } private string _mailContent; public string MailContent { get { return _mailContent; } set { _mailContent = value; } } public static void Send(SendMail mailInfo) { /*发件人的信息*/ string smtp = mailInfo.MailStmp; //发信人所用邮箱的服务器 string mailForm = mailInfo.MailFrom; //发件人的邮箱 string mailPwd = mailInfo.MailPwd; //发件人的密码 string mailTo = mailInfo.MailTo; //收件人信息 string mailTitle = mailInfo.MailTitle; //邮件标题 string mailContent = mailInfo.MailContent; //邮件内容 SmtpClient client = new SmtpClient(smtp, 25); client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(mailForm, mailPwd); /*指定如何处理待发的邮件*/ client.DeliveryMethod = SmtpDeliveryMethod.Network; MailMessage message = new MailMessage(mailForm, mailTo, mailTitle, mailContent); message.BodyEncoding = Encoding.Default; message.IsBodyHtml = true; client.Send(message); //try //{ // MailInfo mi = new MailInfo(); // mi.MailStmp = "" // mi.MailFrom = "@.com"; // mi.MailPwd = ""; // mi.MailTo = "beyondmj0.student@sina.com"; // mi.MailTitle = "Test For Fucking"; // mi.MailContent = "<marquee>123</marquee>"; // SendMail(mi); //} //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} } }
------解决方案--------------------
参考
http://www.cnblogs.com/smallfa/articles/929962.html
http://www.cnblogs.com/zengjun1980/articles/1074825.html
------解决方案--------------------
http://www.cnblogs.com/yank/archive/2008/08/03/1258428.html
http://www.cnblogs.com/voswin/articles/1281522.html
------解决方案--------------------
http://www.cnblogs.com/ustbwuyi/archive/2007/05/28/762581.html
------解决方案--------------------
/**//// <summary>
/// 邮件初始化
/// 为了简单,自己发个自己
/// </summary>
/// <returns></returns>
public MailMessage InitMail(string Address)
{
MailMessage mail = new MailMessage();
//发件人
mail.From = new MailAddress(Address);