Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. help with sending emails

help with sending emails

Scheduled Pinned Locked Moved ASP.NET
help
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kaaj21
    wrote on last edited by
    #1

    can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj

    E B C 3 Replies Last reply
    0
    • K kaaj21

      can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      SmtpMail may require a user name and password as well as a valid from recipient. Also, is your local IIS setup as SMTP?


      Need a C# Consultant? I'm available.
      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

      1 Reply Last reply
      0
      • K kaaj21

        can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj

        B Offline
        B Offline
        brhnz
        wrote on last edited by
        #3

        SmtpMail is obsolete in .net 2.0. Maybe try using the SmtpClient instead. So... SmtpClient client = new SmtpClient( "localhost" ); client.Send( message );

        1 Reply Last reply
        0
        • K kaaj21

          can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj

          C Offline
          C Offline
          cst_cfit
          wrote on last edited by
          #4

          i think these modifications will make it work protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To.Add(new MailAddress(txtTo.Text, "any user Name"); mMail.From = new MailAddress(txtFrom.Text, "any user Name"); message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpClient sm = new SmtpClient(); sm.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } } in web.config, configure smtp think this shud work

          CST

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups