How do I send a web page?

Platform: ASP.NET| Category: Mail

Use namespace System.IO and System.NET
VB.NET

 ’In Page_Load
Dim mailcontenturl As String = 'http://www.syncfusion.com'
Dim mail As New MailMessage()
mail.To = 'manag@syncfusion.com'
mail.From = 'admin@syncfusion.com'
mail.Subject = 'Test.'

’To send webpage 
mail.Body = GetHTML(mailcontenturl)
mail.BodyFormat = MailFormat.Html
mail.UrlContentBase = mailcontenturl

SmtpMail.SmtpServer = 'localhost'
SmtpMail.Send(mail)


’Function GetHTML
Private Function GetHTML(url As String) As String
   	Dim wReq As WebRequest = System.Net.HttpWebRequest.Create(url)
   	Dim sr As New StreamReader(wReq.GetResponse().GetResponseStream())
   	Dim result As String = sr.ReadToEnd()
   	sr.Close()
   	Return result
End Function ’GetHTML

C#

//In Page_Load
string mailcontenturl ='http://www.syncfusion.com';
MailMessage mail = new MailMessage();
mail.To = 'manag@syncfusion.com';
mail.From = 'admin@syncfusion.com';
mail.Subject = 'Test.';

//To send webpage 
mail.Body = GetHTML ( mailcontenturl );
mail.BodyFormat = MailFormat.Html;
mail.UrlContentBase = mailcontenturl;
		
SmtpMail.SmtpServer = 'localhost';  
SmtpMail.Send( mail );

//Function GetHTML
private string GetHTML( string url )
{
	WebRequest wReq= System.Net.HttpWebRequest.Create(url);
	StreamReader sr =  new StreamReader( wReq.GetResponse().GetResponseStream() );  
	string result = sr.ReadToEnd();
	sr.Close();
	return result;
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.