Example #1
0
 protected void SendEmail(object sender, EventArgs e)
 {
     using (StringWriter sw = new StringWriter())
     {
         using (HtmlTextWriter hw = new HtmlTextWriter(sw))
         {
             PlaceHolder1.RenderControl(hw);
             //GridView1.RenderControl(hw);
             StringReader sr = new StringReader(sw.ToString());
             MailMessage  mm = new MailMessage("*****@*****.**", "*****@*****.**");
             mm.Subject    = "GridView Email";
             mm.Body       = "<b>Tan Vo</b>Test:<hr />" + sw.ToString();;
             mm.IsBodyHtml = true;
             SmtpClient smtp = new SmtpClient();
             smtp.Host      = "smtp.logigear.com";
             smtp.EnableSsl = true;
             System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
             NetworkCred.UserName       = "******";
             NetworkCred.Password       = "";
             smtp.UseDefaultCredentials = true;
             smtp.Credentials           = NetworkCred;
             smtp.Port = 587;
             smtp.Send(mm);
         }
     }
 }