How to mail current open Page

  • Thread starter Thread starter Kuldeep
  • Start date Start date
K

Kuldeep

Hi All,

How can i mail the current open page? The open page contains some data
(which vary every time page is opened), textbox to enter email id and
send button. When the send button is clicked i want to mail this page as
it is to the given email id.


regards
 
Hi Kuldeep,
If you are looking to send the content of page as body of the mail to a
recipient then you can follow these steps
1) Keep all the content that has to be mailed inside a panel control.
2) When you send mail the mail format should be Html and the body of the
mail will be the content of the panel.
You can get the content of the panel by using RenderControl. I am pasting
some part of the code which might help you
Dim strWriter As StringWriter = New StringWriter
Dim myTextWriter As HtmlTextWriter = New HtmlTextWriter(strWriter)
Dim mymail As New Mail.MailMessage
mymail.BodyFormat = MailFormat.Html
Panel1.RenderControl(myTextWriter)
mymail.Body = strWriter.ToString
In case you have further questions please revert.
 
Hi everybody,

Thanks for replying to my post and i'm sorry for being late in
responding.

I was able to solve my problem using the following code


Dim wreq As WebRequest =
HttpWebRequest.Create("http://localhost/myPage.aspx")

Dim wrsp As WebResponse = wreq.GetResponse()
Dim sr As StreamReader = New StreamReader(wrsp.GetResponseStream())

Dim strHTML As String = sr.ReadToEnd()
sr.Close()

Dim msg As New MailMessage
msg.From = "(e-mail address removed)"
msg.To = "(e-mail address removed)"
msg.Subject = "HTML page"
msg.Body = strHTML
msg.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(msg)


Regards,
Kuldeep
 
Back
Top