Live Chat Icon For mobile
Live Chat Icon

How do I send a web page?

Platform: ASP.NET| Category: Mail

Use namespace System.IO and System.NET

 ’In Page_Load
Dim mailcontenturl As String = ''
Dim mail As New MailMessage()
mail.To = ''
mail.From = ''
mail.Subject = 'Test.'

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

SmtpMail.SmtpServer = 'localhost'

’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()
   	Return result
End Function ’GetHTML


//In Page_Load
string mailcontenturl ='';
MailMessage mail = new MailMessage();
mail.To = '';
mail.From = '';
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();
	return result;

Share with

Related FAQs

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

Please submit your question and answer.