Sends selected content through Email.
Introduction
Sending Page contents through mail in ASP.NET
First imports system.net.mail namespace.
Try
Dim objmail As New SmtpClient
Dim mailmsg As New MailMessage
mailmsg.To.Clear()
mailmsg.CC.Clear()
mailmsg.IsBodyHtml = True
mailmsg.From = New MailAddress("")
mailmsg.To.Add(New MailAddress(""))
mailmsg.CC.Add("")
mailmsg.Subject = " "
mailmsg.Body = ""
mailmsg.Body = mailmsg.Body + ""
'for page contents
Dim stringWriter As New StringWriter()
Dim htmlTextWriter As New HtmlTextWriter(stringWriter)
DataTable.RenderControl(htmlTextWriter)
mailmsg.Body = mailmsg.Body + stringWriter.ToString()
'''''''''''''''''''
mailmsg.Body = mailmsg.Body + "---------------------------<br />"
objmail.Host = "100.123.54.22"
objmail.Send(mailmsg)
Catch ex As Exception
msgbox(Page, ex.ToString)
End Try
Here, I am trying to send the content of the DataTable to the email.