Go to DotNetFunda.com
 Online : 1602 |  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

 Posted on: 11/15/2008 2:22:32 AM by Patidar.shekhar | Views: 787 | Category: ASP.NET | Level: Intermediate | Print Article
Sends selected content through Email.

.NET Training Videos!
Buy online comprehensive training video pack just for $35.00 only, see what's inside it.

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.

Interesting?   Share and Bookmark this kick it on DotNetKicks.com


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

   ◘ Printing part of the page posted on 11/21/2008 11:04:06 PM
   ◘ Sending Page contents through mail in ASP.NET posted on 11/15/2008 2:22:32 AM
   ◘ Transaction in SQL Server posted on 11/13/2008 5:15:05 AM


Submit Article

About Us | The Team | Advertise | Contact Us | Feedback | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found copied contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
All rights reserved to DotNetFunda.Com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)