smtp - Send Email through c# in asp.net -
this question has answer here:
- sending email in .net through gmail 21 answers
below code of sending email mail getting error please !
error: email not sent!system.net.mail.smtpexception: operation has timed out. @ system.net.mail.smtpclient.send(mailmessage message) @ _default.button1_click(object sender, eventargs e)
try{ mailmessage mailmessage = new mailmessage(); mailmessage.to.add(textbox3.text); mailmessage.from=new mailaddress("sadiazar05@gmail.com"); mailmessage.subject = "user signup"; mailmessage.body = "hello you're registered!"; smtpclient smtpclient = new smtpclient("smtp.gmail.com",465); mailmessage.priority = mailpriority.high; smtpclient.timeout = 60000; smtpclient.send(mailmessage); response.write("email sent successfully!"); } catch(exception exp) { response.write("email not sent!" +exp); } }
you can try this:
try{ // message details mailmessage mailmessage = new mailmessage(); mailmessage.to.add(textbox3.text); mailmessage.from=new mailaddress("sadiazar05@gmail.com"); mailmessage.subject = "user signup"; mailmessage.body = "hello you're registered!"; mailmessage.priority = mailpriority.high; //smtp client details smtpclient.usedefaultcredentials = false smtpclient.credentials = new net.networkcredential("email", "password")// here have give username , password smtpclient.port = 587 // default port gmail smtpclient.enablessl = true smtpclient.host = "smtp.gmail.com" smtpclient.timeout = 60000; smtpclient.send(mailmessage); response.write("email sent successfully!"); } catch(exception exp) { response.write("email not sent!" +exp); } }
Comments
Post a Comment