MailMessage mm = new MailMessage();
mm.From = myReader["FromEmail"].ToString();
mm.To = myReader["ToEmail"].ToString();
mm.Subject = myReader["Subject"].ToString(); ;
mm.Body = strBody;
mm.BodyFormat = MailFormat.Html;
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", myReader["UserName"].ToString()); //set your username here
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", myReader["UserPassword"].ToString()); //set your password here
SmtpMail.SmtpServer = myReader["Smtp"].ToString();
SmtpMail.Send(mm);
mm.From = myReader["FromEmail"].ToString();
mm.To = myReader["ToEmail"].ToString();
mm.Subject = myReader["Subject"].ToString(); ;
mm.Body = strBody;
mm.BodyFormat = MailFormat.Html;
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", myReader["UserName"].ToString()); //set your username here
mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", myReader["UserPassword"].ToString()); //set your password here
SmtpMail.SmtpServer = myReader["Smtp"].ToString();
SmtpMail.Send(mm);
{
string toaddress = txtto.Text.ToString().Trim();
string subject = txtsubject.Text.ToString();
string body = Editor1.Text.ToString();
MailAddress from = new MailAddress("[email protected]");
MailAddress to = new MailAddress(toaddress);
MailMessage message = new MailMessage(from, to);
message.Subject = subject;
message.Body = body;
message.IsBodyHtml = true;
message.SubjectEncoding = System.Text.Encoding.Default;
message.BodyEncoding = System.Text.Encoding.Default; SmtpClient client = new SmtpClient("smtp.163.com");
NetworkCredential smtpuserinfo = new NetworkCredential();
smtpuserinfo.UserName = "123123123";
smtpuserinfo.Password = "123123123";
client.Credentials = smtpuserinfo;
client.Send(message);
}
4楼的用户名和密码是指163.com注册的用户名和密码吧