摘要:寄信程式
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Web.Mail; /// <summary> /// 處理寄信功能程式 /// </summary> public class SendEMailObject { public string SmtpServer =""; public SendEMailObject() { } public string SendEmail(string MailTo, string MailFrom, string Subject, string Body,string SmtpServer) { this.SmtpServer = SmtpServer; return SendEmail(MailTo, MailFrom, Subject, Body); } public string SendEmail(string MailTo, string MailFrom, string Subject, string Body) { string Result; MailMessage Message = new MailMessage(); Message.To = MailTo; Message.From = MailFrom; Message.Subject = Subject; Message.Body = Body; SmtpMail.SmtpServer = this.SmtpServer; try { SmtpMail.Send(Message); Result = "寄送信件成功"; } catch(HttpException http) { Result = http.Message; } return Result; } }