vb.net - ASP.net Contact Form Sending an email error -
i need on 1 thing. have website , in website have contact page in users can contact admin page or other stuff.
the problem when try render page, gives me error saying
the smtp server requires secure connection or client not authenticated. server response was: 5.5.1 authentication required. learn more @ description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.net.mail.smtpexception: smtp server requires secure connection or client not authenticated. server response was: 5.5.1 authentication required. learn more @ source error: line 21: smtp.credentials = networkcred line 22: smtp.port = 587 line 23: smtp.send(mm) line 24: lblmessage.text = "email sent sucessfully." line 25: end sub source file: c:\users\user\desktop\contactusform\vb.aspx.vb line: 23 i don't know wt do. vb behind code :
imports system.net imports system.net.mail partial class vb inherits system.web.ui.page protected sub btnsend_click(byval sender object, byval e eventargs) dim mm new mailmessage("sender@gmail.com", "reveiver@gmail.com") mm.subject = txtsubject.text mm.body = "name: " & txtname.text & "<br /><br />email: " & txtemail.text & "<br />" & txtbody.text if fileupload1.hasfile dim filename string = system.io.path.getfilename(fileupload1.postedfile.filename) mm.attachments.add(new attachment(fileupload1.postedfile.inputstream, filename)) end if mm.isbodyhtml = true dim smtp new smtpclient() smtp.host = "smtp.gmail.com" smtp.enablessl = true dim networkcred new system.net.networkcredential() networkcred.username = "sender@gmail.com" networkcred.password = "senderpassword" smtp.usedefaultcredentials = true smtp.credentials = networkcred smtp.port = 587 smtp.send(mm) lblmessage.text = "email sent sucessfully." end sub end class the error @ line 23 saying smtp.send(mm)
i in need. please can me.
change
smtp.usedefaultcredentials = false your don't want use default credentials, want use credentials created in code.
Comments
Post a Comment