Go to DotNetFunda.com
 Online : 827 |  Welcome, Guest!   Login
 
Home > Articles > ASP.NET > Sending Page contents through mail in ASP.NET

Submit Article | Articles Home | Search Articles |

Sending Page contents through mail in ASP.NET

red flag  Posted on: 11/15/2008 2:22:32 AM by Patidar.shekhar | Views: 926 | Category: ASP.NET | Level: Intermediate


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.


If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Found interesting? Add this to:

| More



Please Sign In to vote for this post.

 
Latest post(s) from Patidar.shekhar

Latest Articles
Experience:1 year(s)
Home page:http://www.dotnetfunda.com
Member since:Thursday, September 25, 2008
Level:Starter
Status: [Member]
Biography:

Submit Article

About Us | The Team | Advertise | Contact Us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 9/3/2010 4:34:11 AM