//Function which convert URL information as string
//Which is used latter to passed as body message.
private String readHtmlPage(string url)
{
String result;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
//Code for sending webpage as email.
private void btnSend_Click(object sender, System.EventArgs e)
{
//URL is converted into string message.
String message=readHtmlPage(txtURL.Text);
String mailServer = "192.168.0.10"; //Change with your mail server address.
try
{
MailMessage Mailer = new MailMessage();
Mailer.From = txtFrom.Text;
Mailer.To = txtTo.Text;
Mailer.Subject = txtSubject.Text;
Mailer.Body = message;
Mailer.BodyFormat = System.Web.Mail.MailFormat.Html;
SmtpMail.Server(mailServer);
SmtpMail.Send(Mailer);
lblResult.Text = "Page successfully sent!";
}
catch(Exception ex)
{
lblResult.Text = "An error occurred: " + ex.ToString();
}
}
This entry is in response to the Conserve, Recycle and Discover contest organised by blogadda.com in association with Pringoo ! World Environment Day, commemorated on 5 June since 1972, is one of the ways focuses world attention on the environment and encourages political action. People from countries all over the world have mobilized for individual and organized environmental action. Activities involve all sectors of society, governments, non- and inter-governmental organizations, businesses, industries, civil society, media and schools. Please take the following Pledge to save our environment. 1, I pledge to Recycle more, use less water and electricity. 2, I pledge to smoke less in 2010. 3, I pledge to send more electronic documents instead of using paper. 4, I pledge to continue using my bicycle to go to work (instead of my motorbike). 5, wash with full loads it is more energy efficient than doing several smaller ones. 6, Incite of dryer I will use hang dry for energy sav...
Comments