Send a Datagrid contents as an Email message

T

Tips

The code below renders a datagrid and send its contents by email.


Dim SB as New StringBuilder()
Dim SW as New StringWriter(SB)
Dim htmlTW as New HtmlTextWriter(SW)
YOUR_DATAGRID.RenderControl(htmlTW)

Dim dataGridHTML as String = SB.ToString()

Dim MyMail As MailMessage = New MailMessage()
MyMail.From = From
MyMail.To = To
MyMail.Subject = Subject
MyMail.Body = dataGridHTML
MyMail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = MailServer
SmtpMail.Send(MyMail)

Source : http://www.mycodebank.com/Snippet,78.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top