Hi,
Happy morning to all,
I have a requirement , i ,e i need to send webpage as email, how to send that one, please give the guidence to solve this requirement.
Thank you
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Upamanyu Roy Choudhury146 reputationPosted Feb 20, 2013, 9:44 PM EST
System.Web.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 class.
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
mail.Subject = "this is a test email.";
string url = "http://www.microsoft.com";
mail.Body = HttpContent( url );
mail.BodyFormat = MailFormat.Html;
mail.UrlContentBase = url;
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
}
//screen scrape a page here
private string HttpContent( string url )
{
WebRequest objRequest= System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader( objRequest.GetResponse().GetResponseStream() );
string result = sr.ReadToEnd();
sr.Close();
return result;
}
Hope this helps.
Prabhakar Reddy101 reputationPosted Feb 20, 2013, 11:06 PM EST
Upamanyu Roy Choudhury
Upamanyu Roy Choudhury146 reputationPosted Feb 20, 2013, 11:24 PM EST
Please mark it as an answer if my post is useful to you
Prabhakar Reddy101 reputationPosted Feb 24, 2013, 7:37 PM EST
Am getting this error, how t o resolve this one.
The message could not be sent to the SMTP server. The transport error code was 0x800ccc62. The server response was 500 Line limit exceeded