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); 

解决方案 »

  1.   

    要导入 using System.Net.Mail;看看我最近写的!不是很好,不过也许有帮助! public void SentMial()
        {
            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);
        }
      

  2.   

    能不能不验证username password啊,毕竟人家要是点button 最多只会给你用户名,密码不会给啊
      

  3.   

    LS 
    4楼的用户名和密码是指163.com注册的用户名和密码吧
      

  4.   

    <a href="mailto:?subject=<%#txtSub.Text%>&amp;body=<%#TextBox1.Text%>><font style="FONT-WEIGHT: bold" id="FONT1">转发邮件</font></a>