c# - Mail Error:The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required -
i using following code send email. code not working getting error message
try { mailmessage message = new mailmessage(mfrom, "xyz@gmail.com",msubject,mmsg); smtpclient mysmtpclient = new smtpclient("smtp.gmail.com",587); mysmtpclient.credentials = icredentialsbyhost)credentialcache.defaultnetworkcredentials; mysmtpclient.deliverymethod = smtpdeliverymethod.network; mysmtpclient.usedefaultcredentials = true; mysmtpclient.enablessl = true; mysmtpclient.send(message); } catch (formatexception ex) { messagebox.show(ex.stacktrace, ex.message, messageboxbuttons.ok, messageboxicon.error); } catch (smtpexception ex) { messagebox.show(ex.stacktrace, ex.message, messageboxbuttons.ok, messageboxicon.error); } catch (exception ex) { messagebox.show(ex.stacktrace, ex.message, messageboxbuttons.ok, messageboxicon.error); }
the following smtpexception exception been catched
the smtp server requires secure connection or client not authenticated. server response was: 5.5.1 authentication required.
thanks...
Comments
Post a Comment