Home  >  Esempi di Codice
 
Emailing a Table Web control via an ASP.NET Web page ASP.net3/31/2005ZIP
< Prev   Next >

Questo esempio mostra come inviare il risultato del rendering di un web control all'interno di una E-mail in formato HTML.

/* Sendes the HTML turning out from the table web Control for email */

publicvoid sendHtmlforEmail(){

//Create an instance of the StringBuilder class
StringBuilder sb= newStringBuilder();
StringWriter sw= newStringWriter(sb);
HtmlTextWriter htw= newHtmlTextWriter(sw);
//Render Table Control to HtmlTextWriter
Table1.RenderControl(htw);
stringhtmlTXT=sb.ToString();

//Create an instance of the MailMessage class
MailMessage msg=new MailMessage();
msg.BodyFormat = MailFormat.Html;
//set To
msg.To = "To";
//set from
msg.From = "YourEmailAddress";
//set SMTP server
SmtpMail.SmtpServer="SMTPAddress";
//Set the subject
msg.Subject = "Table Emailing";
//Set the body
msg.Body = "This is an example of emailing a Table Web control via an ASP.NET Web page.
" + htmlTXT;

SmtpMail.Send(msg);
}


 
Sito aggiornato il 02/05/2008 Sito realizzato da   Ilaria Cinci