Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,

I have two aspx pages say, 1.aspx and 2.aspx, in 1.aspx page i have a button on clicking the button the page will redirect to the next page i.e., 2.aspx carrying the values of 1.aspx page. This 2.aspx page is totally designed in code behind. now the point is, in 2.aspx page i have a button, now i want to mail this 2.aspx page to an email id using that button.. how can i do this, please help me out fnds....
Posted
Comments
bbirajdar 11-May-12 6:37am    
Duplicate

http://www.codeproject.com/Questions/382208/Save-Send-a-ASP-NET-Page-from-the-Server-Side
Sandeep Mewara 11-May-12 9:15am    
Where are you stuck? You were already replied.

1 solution

Try something like:

Email Authentication:
XML
<system.net>
     <mailsettings>
	 <smtp>
	     <network host="smtp.domain.com" port="25" username="user@domain.com" password="$0M3Pa@$5w0D" />
	  </smtp>
     </mailsettings>
</system.net>


C#
String html = String.Empty;
try
{
   WebClient web = new WebClient();
   Byte[] bytes;
   // Change url to maybe: http://localhost:10101/2.aspx
   bytes = web.DownloadData( "http:www.domain.com/page.aspx" );
   UTF8Encoding oUTF8 = new UTF8Encoding();
   // Get the html returned from the page/url
   html = oUTF8.GetString( bytes );
   
   // Send the message
   MailMessage mail = new MailMessage( "sender@mail.com", "receiver@mail.com" );
   SmtpClient smtp = new SmtpClient();
   mail.Subject = "Message Subject";
   mail.Body = html;
   mail.IsBodyHtml = true; // It says e-mail clients should render this as html
   smtp.Send( mail ); // ... and, send it!
}
catch( Exception up )
{
   throw up; // Handle your errors accordingly, or leave as is to throw up.
}


Happy ...ending,
Morgs
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900