using System.Web.Mail;
MailMessage mm = new MailMessage(); //实例化MailMessage对象
mm.From = MailInfo.FromName;
mm.To = MailInfo.Receiver;
mm.Subject = "邮件的标题";
mm.BodyFormat = MailFormat.Html; //邮件格式,有HTML与Text两种
mm.Body = "这里是邮件的正文内容,配合上面的MailFormat的格式编写内容";
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",MailInfo.UserName);
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",MailInfo.UserPwd);
SmtpMail.SmtpServer = MailInfo.SmtpServer; //指定发件服务器的地址
try{
SmtpMail.Send(mm); //执行发送操作
}catch(Exception ex){
ErrLog.Writeln(ex.Message); //发送失败,将失败的原因记录到日志中
}
mm.From = MailInfo.FromName;
mm.To = MailInfo.Receiver;
mm.Subject = "邮件的标题";
mm.BodyFormat = MailFormat.Html; //邮件格式,有HTML与Text两种
mm.Body = "这里是邮件的正文内容,配合上面的MailFormat的格式编写内容";
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",MailInfo.UserName);
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",MailInfo.UserPwd);
SmtpMail.SmtpServer = MailInfo.SmtpServer; //指定发件服务器的地址
try{
SmtpMail.Send(mm); //执行发送操作
}catch(Exception ex){
ErrLog.Writeln(ex.Message); //发送失败,将失败的原因记录到日志中
}