![]() |
|
|
|
#1 |
|
Hi
I am novice to ASP.Net and this is my first project in ASP.Net. I need to mail a webpage when the user clicks the submit button. I am trying for two days but couldn't make it. Here's my code: Dim mymail As New MailMessage() Dim mailcontenturl As String = "http://www.microsoft.com" mymail.From = "" mymail.To = "" mymail.Subject = "test" mymail.BodyFormat = MailFormat.Html mymail.Body = getHTML(mailcontenturl) mymail.Priority = MailPriority.High mymail.UrlContentBase = mailcontenturl SmtpMail.Send(mymail) Response.Write("mail sent") End If End Sub Private Function getHTML(ByVal url As String) As String Dim wreq As WebRequest = System.Net.HttpWebRequest.Create(url) Dim wres As WebResponse = wreq.GetResponse Dim sr As New StreamReader(wres.GetResponseStream()) Dim result As String = sr.ReadToEnd sr.Close() Return result End Function The following error comes: The underlying connection was closed: An unexpected error occurred on a receive. I also increased the connection timeout time but that also didnt help. Pls help. Regards, Ashima ashima515 |
|
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Mar 2007
Posts: 1
|
Hey use this...
using System.Web.Mail; and write on page,button or anywhere... MailMessage objMail = new MailMessage(); objMail.To = txtemail.Text; objMail.From = ""; objMail.Subject = "New Registration"; objMail.Body = "Welcome " + txtDName.Text + "<br><br><br>_____________________________________ ___________________ "; objMail.Body = objMail.Body + "<br>" + " Your Registration is done." + "<br>" + "UserName=" + txtUserName.Text; objMail.Body = objMail.Body + "<br>" + "Password:" + txtPassword.Text + "<br>" + "Registration Code:" + "00"; objMail.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = "mail server name"; SmtpMail.send(objmail); The above code is tested and working fine... Thanks Rocky email: Rockyrock007 |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| .NET 2.0 Web Apps / .NET 3.5 ASP.NET Apps - Differences/Similariti | london1919 | MCTS | 1 | 12-08-2008 03:16 PM |
| ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) | msandlana | Software | 0 | 04-25-2008 06:37 AM |
| ASP.NET 2.0 application does not run in WIN2k3 | johnfraj | Software | 0 | 04-19-2007 08:27 AM |
| Problem accessing query in the design mode MS access | shieldguy | Software | 0 | 11-07-2006 02:45 PM |
| ASP.net 2.0 C# dynamic query | paulnf | Software | 0 | 10-03-2006 04:46 AM |