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. SMTP Exception

SMTP Exception

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netcomsysadmin
4 Posts 2 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.
  • D Offline
    D Offline
    DKalepu
    wrote on last edited by
    #1

    Hi All, first of all, I am extremely sorry for asking the same question again! my problem is i am trying to send an email in asp.net 2.0. But I keep on getting an exception whenever i try to send.. Here is the exception Send failure: System.Net.Mail.SmtpException: The operation has timed out. at System.Net.Mail.SmtpClient.Send(MailMessage message) at Default2.btnSubmit_Click(Object sender, EventArgs e) and here is my code: protected void btnSubmit_Click(object sender, EventArgs e) { SmtpClient smtpClient = new SmtpClient(); MailAddress objMail_From = new MailAddress("username@gmail.com"); MailAddress objMail_To = new MailAddress("username@gmail.com"); MailMessage objMail = new MailMessage(objMail_From, objMail_To); objMail.Subject = "Email-Test Example"; objMail.IsBodyHtml = true; objMail.Body = "Sending E-mails with ASP.NET 2.0 using CSharp" + "

    Company : " + lblCompany1.Text + "

    " + "

    Address : " + lblAddress1.Text + "

    " + "

    Telephone :" + lblTelephone1.Text + "

    " + "

    Fax :" + lblFax1.Text + "

    " + "

    Email : " + lblEmail1.Text + "

    " + "

    Comments : " + lblComments1.Text + "

    " + ""; objMail.Priority = MailPriority.High; smtpClient.Host = "smtp.yahoo.com"; smtpClient.Credentials = new System.Net.NetworkCredential("username@gmail.com", "xxxxxx"); smtpClient.UseDefaultCredentials = false; smtpClient.EnableSsl = true; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; try { smtpClient.Send(objMail); Response.Write("Your mail has been sent"); } catch (Exception exc) { Response.Write("Send failure: " + exc.ToString()); } } and in the web.config i put it like this: _________ could any one please help me on this... plz.. Thank in Advance.

    S 1 Reply Last reply
    0
    • D DKalepu

      Hi All, first of all, I am extremely sorry for asking the same question again! my problem is i am trying to send an email in asp.net 2.0. But I keep on getting an exception whenever i try to send.. Here is the exception Send failure: System.Net.Mail.SmtpException: The operation has timed out. at System.Net.Mail.SmtpClient.Send(MailMessage message) at Default2.btnSubmit_Click(Object sender, EventArgs e) and here is my code: protected void btnSubmit_Click(object sender, EventArgs e) { SmtpClient smtpClient = new SmtpClient(); MailAddress objMail_From = new MailAddress("username@gmail.com"); MailAddress objMail_To = new MailAddress("username@gmail.com"); MailMessage objMail = new MailMessage(objMail_From, objMail_To); objMail.Subject = "Email-Test Example"; objMail.IsBodyHtml = true; objMail.Body = "Sending E-mails with ASP.NET 2.0 using CSharp" + "

      Company : " + lblCompany1.Text + "

      " + "

      Address : " + lblAddress1.Text + "

      " + "

      Telephone :" + lblTelephone1.Text + "

      " + "

      Fax :" + lblFax1.Text + "

      " + "

      Email : " + lblEmail1.Text + "

      " + "

      Comments : " + lblComments1.Text + "

      " + ""; objMail.Priority = MailPriority.High; smtpClient.Host = "smtp.yahoo.com"; smtpClient.Credentials = new System.Net.NetworkCredential("username@gmail.com", "xxxxxx"); smtpClient.UseDefaultCredentials = false; smtpClient.EnableSsl = true; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; try { smtpClient.Send(objMail); Response.Write("Your mail has been sent"); } catch (Exception exc) { Response.Write("Send failure: " + exc.ToString()); } } and in the web.config i put it like this: _________ could any one please help me on this... plz.. Thank in Advance.

      S Offline
      S Offline
      szukuro
      wrote on last edited by
      #2

      DKalepu wrote:

      smtpClient.Host = "smtp.yahoo.com"; smtpClient.Credentials = new System.Net.NetworkCredential("username@gmail.com", "xxxxxx");

      Gmail credentials with yahoo smtp server?:confused: You probably should use Gmail's smtp in this case.

      D 1 Reply Last reply
      0
      • S szukuro

        DKalepu wrote:

        smtpClient.Host = "smtp.yahoo.com"; smtpClient.Credentials = new System.Net.NetworkCredential("username@gmail.com", "xxxxxx");

        Gmail credentials with yahoo smtp server?:confused: You probably should use Gmail's smtp in this case.

        D Offline
        D Offline
        DKalepu
        wrote on last edited by
        #3

        oops...... I pardon for it! that was such a silly mistake... :mad: i hv changed it to gmail smtp..it throws anoter exception now: Send failure: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required z15sm3365130pod at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at Default2.btnSubmit_Click(Object sender, EventArgs e) in ------

        S 1 Reply Last reply
        0
        • D DKalepu

          oops...... I pardon for it! that was such a silly mistake... :mad: i hv changed it to gmail smtp..it throws anoter exception now: Send failure: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required z15sm3365130pod at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at Default2.btnSubmit_Click(Object sender, EventArgs e) in ------

          S Offline
          S Offline
          szukuro
          wrote on last edited by
          #4

          I tried you code and it seems the line smtpClient.UseDefaultCredentials = false; causes this Exception, so I commented it out and then it worked just fine.

          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