HI
I am trying to mail a web page in asp.net. Some of the pages get mailed bhut some are giving error "The remote server returned an error: (500) Internal Server Error. ". I fail to understand this?
Here's the code m using
Dim mymail As New MailMessage()
Dim mailcontenturl As String = "http://localhost:9000/mailchk/WebForm1.aspx"
mymail.From = "ashima@yahoo.com"
mymail.To = "ashima@gmail.com"
mymail.Subject = "Test Mail Delivery"
mymail.BodyFormat = MailFormat.Html
mymail.Body = getHTML(mailcontenturl)
mymail.Priority = MailPriority.High
mymail.UrlContentBase = mailcontenturl
SmtpMail.Send(mymail)
Response.Write("mail sent")
End Sub
Private Function getHTML(ByVal url As String) As String
Dim wreq As HttpWebRequest
wreq = HttpWebRequest.Create(url)
Dim p As New WebProxy("http://isasrv.del.techbooks.com:8080")
wreq.Proxy = p
wreq.Credentials = CredentialCache.DefaultCredentials
Dim wres As HttpWebResponse
wres = wreq.GetResponse()
Dim sr As New StreamReader(wres.GetResponseStream(), System.Text.Encoding.UTF8)
Dim result As String = sr.ReadToEnd()
sr.Close()
wreq.Timeout = 10000
' wreq.KeepAlive = False
Return result
End Function
Pls suggest what m doing wrong.
Thanks & Regards,
Ashima