MailMessage mail = new MailMessage(); mail.To.Add("aarohi_verma@gmail.com"); mail.From = new System.Net.Mail.MailAddress("info@mywebsitename.com"); mail.Subject = "Testing from code..!"; mail.IsBodyHtml = true; mail.Body = string.Format("<html><body><b>Dear</b>" + " <font> Hello THis is for just testing </font><br/><br/>" + "</body></html>"); SmtpClient smtp = new SmtpClient(); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential("info@mywebsitename.com", "my mail password from control panel"); smtp.EnableSsl = true; smtp.Send(mail);
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 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Mail.SmtpException: 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 Source Error: Line 49: Line 50: smtp.EnableSsl = true; Line 51: smtp.Send(mail); Line 52: } Line 53: }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)