Hi all!
I have a problem emailing the whole contents of a page to a specified e-mail address, using HttpWebRequest Class' object. Following is what I am doing:
Public Sub mailthispage()
Dim html As String = catchHtml("http://localhost:8080/myfile.aspx?did=240&type=mail")
Dim email As New System.Net.Mail.MailMessage()
email.From = New System.Net.Mail.MailAddress("[email protected]")
email.To.Add("[email protected]")
email.Subject = "This page is emailed"
mail.Body = html
mail.IsBodyHtml = True
Dim smtp As New System.Net.Mail.SmtpClient("127.0.0.1")
smtp.Send(email)
End Sub
Public Function catchHtml(ByVal URL As String) As String
Dim reg As WebRequest
req= New System.Net.HttpWebRequest.Create(url)
Dim Stream As New StreamReader(req.GetResponse().GetResponseStream() )
Dim result As String = Stream.ReadToEnd()
Stream.Close()
Return result
End Function
I am calling
mailthispage() at load if the querystring's type value is e-mail. Now this is giving error, The remote server returned an error: (401) Unauthorized.
Can anyone guide me solve this?
regards
Mykhan
Life is a quest and Love is a Quarrel