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.Net.Mail;
using System.Net;
/// <summary>
/// EmailPost 的摘要說明
/// </summary>
public class EmailPost
{
public EmailPost()
{
//
// TODO: 在此處添加構造函數邏輯
//
}
public static string PostEmail(string MailTitle,string MailBody,string RequestEmail)
{
string Poster = "[email protected]"; //發送者郵箱地址
string PosterPwd = "********";//發送者郵箱密碼
string SmtpHost = "smtp.163.com"; //發送郵件服務器
string getstr = "";
MailMessage mailmsg = new MailMessage();
mailmsg.From = new MailAddress(Poster); //定義發件人
mailmsg.To.Add(RequestEmail); //添加收件人
mailmsg.Subject = MailTitle; //郵件標題
mailmsg.Body =MailBody; //郵件內容
//return SendEmail(mailmsg);
SmtpClient smtpClient = new SmtpClIEnt();
//smtpClIEnt.EnableSsl = true;
smtpClIEnt.Host = SmtpHost;
//smtpClIEnt.Port = 465;
smtpClIEnt.Credentials = new NetworkCredential(Poster, PosterPwd);
try
{
smtpClIEnt.Send(mailmsg);
getstr += "發送成功";
}
catch
{
getstr += "發送失敗";
}
return getstr;
}
}