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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prabhakar ReddyPosted Feb 25, 2013, 12:37 AM
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
Upamanyu Roy ChoudhuryPosted Feb 21, 2013, 4:24 AM
Please mark it as an answer if my post is useful to you
Prabhakar ReddyPosted Feb 21, 2013, 4:06 AM
Upamanyu Roy Choudhury
Upamanyu Roy ChoudhuryPosted Feb 21, 2013, 2:44 AM
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.