To send a mail using asp.net(c#)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muskan
    New Member
    • Nov 2006
    • 35

    To send a mail using asp.net(c#)

    hello,

    I want to write the application in which if I click on send button then message sent to particular URL.

    could u help me to solve my prob.
  • josephkind
    New Member
    • Dec 2006
    • 2

    #2
    Originally posted by muskan
    hello,

    I want to write the application in which if I click on send button then message sent to particular URL.

    could u help me to solve my prob.
    Hi In order to send mail to particular email address
    1.please configure SMTP server in your system
    2.use namespaces using sytem.web and system.web.mail

    U will get all the requiared functions from this two namespaces

    Comment

    • ravichandran
      New Member
      • Dec 2006
      • 2

      #3
      hai
      i had tested with System.web.mail in VS 2005but i got only error saying obsulete method so i tried with System.net.mail no error but the message is not send

      Try with System.Net class
      *************** *************** *************** ****
      sample code

      StringWriter str = new StringWriter();
      System.Net.Mail .MailMessage mes = new System.Net.Mail .MailMessage("r chandran.t@gmai l.com", "nglravi@rediff mail.com");
      HtmlTextWriter htw = new HtmlTextWriter( str);
      htw.RenderBegin Tag("html");
      htw.RenderBegin Tag("title");
      htw.Write("Than k u " + TextBox1.Text);
      htw.RenderEndTa g();
      htw.RenderEndTa g();
      htw.RenderBegin Tag("Body");
      htw.WriteLine(" Thank u for registering with us");
      htw.RenderEndTa g();


      mes.Subject = "Auto reply";
      mes.Body = htw.ToString();
      try
      {
      System.Net.Mail .SmtpClient smpt = new System.Net.Mail .SmtpClient("lo cal");
      smpt.Send(mes);
      }
      catch (Exception ee)
      {
      Response.Write( ee.Message);
      }
      }
      *************** *************** ***********

      if any error kindly correct

      Comment

      Working...