Go Back   Velocity Reviews > General Computer Discussion > Software
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
Old 11-17-2006, 08:31 AM   #1
Default asp.net query


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
ashima515 is offline   Reply With Quote
Old 03-02-2007, 06:29 AM   #2
Rockyrock007
Junior Member
 
Join Date: Mar 2007
Posts: 1
Default
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
Rockyrock007 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46