| Author: Anjali Sharma 14 Jul 2008 | Member Level: Gold | Rating:  Points: 6 |
hi //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(); }}
|
| Author: Biju 14 Jul 2008 | Member Level: Gold | Rating:  Points: 6 |
Dim objEmail as New MailMessage() objEmail.To = txtTo.Text objEmail.From = txtFrom.Text objEmail.Cc = txtCc.Text objEmail.Subject = "Test Email" objEmail.Body = txtName.Text & ", " &txtComments.Text objEmail.Priority = MailPriority.High 'SmtpMail.SmtpServer = "localhost" try SmtpMail.Send(EMail) Response.Write(Your E-mail has been sent sucessfully - _ Thank You)
catch exc as Exception Response.Write("Send failure: " + exc.ToString()) End Try
|
| Author: Sreehari 14 Jul 2008 | Member Level: Silver | Rating:  Points: 6 |
The Error message clearly says that your web server from which you are sending mails is not configured with SMTP.YOu will first need to configure SMTP in your server.
Now once you have configured this server you can either make this server as the mail sevrver or if you already have another mail server you can make this server to relay through the dedecated server(ie make this server sent mail through the other)
For that you can go to the properties of smtp and configure relay.
Sreehari www.codeincsharp.com
|