473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to mail a web page in ASP.Net

Hi
I am trying to mail a web page in ASP.Net for last 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 = "ashima515@yahoo.com"
mymail.To = "it.ashima@gmail.com"
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

I am getting the following error :
The underlying connection was closed: An unexpected error occurred on a receive

I also increased the connection timeout but it didn't help. I am novice to ASP.Net. Please help me to fix it.

Thanks & Regards,
Ashima
Nov 17 '06 #1
6 1964
Hi
I am trying to mail a web page in ASP.Net for last 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 = "ashima515@yahoo.com"
mymail.To = "it.ashima@gmail.com"
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

I am getting the following error :
The underlying connection was closed: An unexpected error occurred on a receive

I also increased the connection timeout but it didn't help. I am novice to ASP.Net. Please help me to fix it.

Thanks & Regards,
Ashima
Try some local page that is on your server by giving its url.
Nov 17 '06 #2
Try some local page that is on your server by giving its url.
Whenever I do this, I get the following error

WebException: The remote server returned an error: (401)
Unauthorized.
Nov 21 '06 #3
sashi
1,754 Expert 1GB
Whenever I do this, I get the following error

WebException: The remote server returned an error: (401)
Unauthorized.
Hi there,

Error code (401) refer to "HTTP Error 401 - Unauthorized", check file/path permission. Good luck & Take care.
Nov 21 '06 #4
Hi there,

Error code (401) refer to "HTTP Error 401 - Unauthorized", check file/path permission. Good luck & Take care.
I am novice to ASP.Net
So can you pls tell from where do I check the file/path permissions?

Regards,
Ashima
Nov 21 '06 #5
sashi
1,754 Expert 1GB
I am novice to ASP.Net
So can you pls tell from where do I check the file/path permissions?

Regards,
Ashima
Hi there,

Try to modify your code as outlined below, kindly refer to below code segment, hope it helps. Good luck & take care.

before modification
Expand|Select|Wrap|Line Numbers
  1.   Dim mailcontenturl As String = "http://www.microsoft.com"
  2.  
after modification
Expand|Select|Wrap|Line Numbers
  1.   Dim mailcontenturl As String = "http://www.your_own_domain.com"
  2.  
Nov 21 '06 #6
Hi there,

Try to modify your code as outlined below, kindly refer to below code segment, hope it helps. Good luck & take care.

before modification
Expand|Select|Wrap|Line Numbers
  1.   Dim mailcontenturl As String = "http://www.microsoft.com"
  2.  
after modification
Expand|Select|Wrap|Line Numbers
  1.   Dim mailcontenturl As String = "http://www.your_own_domain.com"
  2.  

Hi
When mailcontenturl=htp://localhost:9000/dg/WebForm1.aspx following error comes

The remote server returned an error: (401) Unauthorized.

How can I fix this?

Thanks & Regards,
Ashima
Nov 22 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: TMN | last post by:
We have an ASP-based call center application that our call center operators use to track calls and forward job assignments. This app replaces a VB6-based client-server app used previously. In the...
5
by: Olaf | last post by:
I have a ASP page that after saveing data to the database it will write the following script code to the page: <script>...
5
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. ...
3
by: Kuldeep | last post by:
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...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
4
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. ...
1
by: vinodkus | last post by:
Problem 1I m writing a mail program in asp my first page is mail.asp where I subitting address, subject, body and second page is send_mail.asp Contents of Page mail.asp <html> <head> <meta...
2
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how...
0
by: anu b | last post by:
Now i am sending email to my friend using session variable... but my code is as below private bool SendEmail(string email) { try {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.