Sending Page contents through mail in ASP.NET

Patidar.shekhar
Posted by in ASP.NET category on for Intermediate level | Views : 3473 red flag

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.

Page copy protected against web site content infringement by Copyscape

About the Author

Patidar.shekhar
Full Name: Shekhar Patidar
Member Level: Starter
Member Status: Member
Member Since: 9/25/2008 1:30:38 AM
Country:

http://www.dotnetfunda.com

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)