62,046
社区成员
发帖
与我相关
我的任务
分享
//用 System.Web.Mail 的写法
MailMessage mail = new MailMessage();
mail.To = txtMailTo.Text; //收件人,多个收件人用 ; 号隔开,很是灵活
mail.Subject = txtSubject.Text; //主题
mail.Body = txtBody.Text; //内容
mail.BodyFormat = MailFormat.Html;
mail.Priority = MailPriority.Normal;
//显示的发件人
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress", "gaosheng@hotmail.com");
//实际发件人
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", "hbgx@hotmail.com");
//用户名
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "hbgx");
//密码
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xgbh");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //验证级别
SmtpMail.SmtpServer = "smtp.hotmail.com";
SmtpMail.SmtpServer.Insert(0, "smtp.hotmail.com");
SmtpMail.Send(mail);