using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
namespace BookShop.Web.test
{
public partial class SendEmail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("XXXXX@163.com", "发件人");//原邮件地址,发件人
mail.To.Add(new MailAddress( "@qq.com","接收"));//目的邮件地址,可以有多个人
mail.Subject = "Hello,大家好!";//发送邮件的标题
mail.Body = "<font color='red'>点击回复</font>";//发送邮件内容
mail.IsBodyHtml = true;
//SMTP服务器
SmtpClient client = new SmtpClient("smtp.163.com");
client.Credentials = new NetworkCredential("xxxx", "密码");//获取或者设置用户验证发件人的凭据 用户名和密码初始化
client.Send(mail);
}
}
}