asp.net发送邮箱
时间:2011-02-22 来源:双魂人生
我们可以是同微软提供的Mail邮件发送方式
下面就是使用邮箱发送的代码:
//创建邮件信息
MailMessage mailMessage = new MailMessage();
mailMessage.From = "发送的邮箱地址";
mailMessage.To = "收件箱地址";
mailMessage.Subject ="主题"
mailMessage.BodyFormat = MailFormat.Html;
StringBuilder strBody = new StringBuilder();
strBody.Append("<div>大家好!我是");
strBody.Append(userName);
strBody.Append("</div>");
mailMessage.Body = strBody.ToString();
SmtpMail.SmtpServer = "smtp.163.com" || "smtp.sina.com";
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//用户名
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名");
//密码
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");
//开始发送
SmtpMail.Send(mailMessage);
下面总结了一下发送邮件的方法,供大家使用
public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
{
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(strSmtpServer);
client.UseDefaultCredentials = false;
client.Credentials =
new System.Net.NetworkCredential(strFrom, strFromPass);
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message =new System.Net.Mail.MailMessage(strFrom, strto, strSubject, strBody);
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
client.Send(message);
}

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />
飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />
飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />
飞行射击 下载- 4 <img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />下载73.78MB · 99℃
1970-01-01
- 5 <img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />下载43.7 MB · 97℃
1970-01-01
- 6 <img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />下载110.69MB · 98℃
1970-01-01