0

Hello I am getting error, An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll

Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.

I have code in console application for email:

``

`In asp console application:


 internal class Program
    {
        static void Main(string[] args)
        {
            string FromMail = "applitech.infotech.itsolution@gmail.com";
            string Password = "officeuser#";
            MailMessage m = new MailMessage();

            m.From = new MailAddress(FromMail);
            m.Subject = "tEST";
            m.To.Add(new MailAddress("sumitranandanbgp96@gmail.com"));
            m.Body = "This is body";
            m.IsBodyHtml = true;

            var smtpClient = new SmtpClient("smtp.gmail.com")
            {
                Port = 587,
                Credentials = new NetworkCredential(FromMail, Password),
                EnableSsl = true
                //UseDefaultCredentials = false
            };
            smtpClient.Send(m);
            Console.WriteLine("completed");
           
        }
    }

please help me.

0 Answers0