stmp发送邮件asp教程.net实现代码
我们使用SmtpMail类方案能满足大部分基本的发送邮件的功能需求嗾。
public class Mail
{
#region 邮件参数
static public string accountName = System.Configuration.ConfigurationManager.AppSettings["SmtpAccountName"];
static public string password = System.Configuration.ConfigurationManager.AppSettings["SmtpAccountPW"];
static public string smtpServer = System.Configuration.ConfigurationManager.AppSettings["SmtpServer"];
static public int smtpPort = int.Parse(System.Configuration.ConfigurationManager.AppSettings["SmtpPort"]);
#endregion///
/// 邮件发送方法一
///
///
///
///
static public void SendMail(string sendTo, string subject, string body)
{
//.net smtp
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.To = sendTo;
//mailmsg.Cc = cc;
mailmsg.Subject = subject;
mailmsg.Body = body;
mailmsg.BodyFormat = MailFormat.Html;
//sender here
mailmsg.From = Mail.accountName;
// certify needed
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");//1 is to certify
//the user id
mailmsg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendusername",
Mail.accountName);
//the password
mailmsg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendpassword",
Mail.password);System.Web.Mail.SmtpMail.SmtpServer = Mail.smtpServer;
System.Web.Mail.SmtpMail.Send(mailmsg);
}
///
/// 邮件发送方法二
///
///
///
///
static public void SendMail2(string sendTo, string subject, string body)
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(accountName, sendTo, subject, body);
msg.From = new System.Net.Mail.MailAddress(accountName, "Mail");
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(smtpServer);
msg.IsBodyHtml = true;
client.Credentials = new System.Net.NetworkCredential(accountName, password);
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;client.Send(msg);
}
}
迷你世界越南服 安卓版v1.7.15
迷你世界越南服是一款精美的3D沙盒游戏,拥有极高的创作自由度
糖饼外传内置菜单 安卓版v1.0.87
糖饼外传内置菜单是一款非常好玩的模拟经营类手游,玩家在游戏中
我的世界化学交换空岛整合包 最新版v1.0
我的世界化学交换空岛整合包是一款像素风格的沙盒生存游戏,游戏
创造厨房免广告版 v1.0.10
创造厨房无广告版是一款像素风模拟经营类手游,玩家们将在这里化
SimCity BuildIt无限金币版 安卓修改版v1.60.1.133743
SimCity BuildIt无限金币版是经过破解的版本,在