System.Net.Mail does not natively support sending a web page. However, using the WebRequest class, you can screen scrape web pages, and pass the resulting Html string to the MailMessage object. The following example demonstrates this technique.
public static void EmailWebPage()
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress(“me@mycompany.com”);
mail.To.Add(“you@yourcompany.com”);
//set the content
mail.Subject = “This is an email”;
//screen scrape the html
string html = ScreenScrapeHtml(“http://localhost/example.htm”);
mail.Body = html;
mail.IsBodyHtml = true;
//send the message
SmtpClient smtp = new SmtpClient(“127.0.0.1″);
smtp.Send(mail);
}
public static string ScreenScrapeHtml(string url)
{
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
return result;
}
hi i run this code ,i get 404 page not found error.
In your app example.htm file is there??
Please add one web page in your app 404 error is page not found error
beconz i think you are not declare example.html in yor app
plz check once