I use below code to mail config .thats works in other applications but my application shows the below error how to fix it.
Msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();smtp.Host = ConfigurationManager.AppSettings["MailServer"];
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
Msg.From = new MailAddress(ConfigurationManager.AppSettings["MailFrom"]);
NetworkCred.Password = ConfigurationManager.AppSettings["MailPassword"];
smtp.Credentials = NetworkCred;
smtp.Port = 25;
smtp.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, System.Security.Cryptography.X509Certificates.X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
smtp.Send(Msg);
Error
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at


Amit GuptaRank #190 · 12.8K reputationPosted Apr 26, 2017, 10:44 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Apr 26, 2017, 7:49 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Apr 26, 2017, 8:08 AM EDT
RajaRank #1,035 · 1.9K reputationPosted Apr 26, 2017, 8:03 AM EDT
Amit Gupta
RajaRank #1,035 · 1.9K reputationPosted Apr 26, 2017, 8:04 AM EDT
RajaRank #1,035 · 1.9K reputationPosted Apr 26, 2017, 9:24 PM EDT
Amit Gupta