When I m trying to send mail through my C# Code above error is showing. I have searched for possibly all solution but I do not get the solution. I am using the below Code:
MailMessage mail = new MailMessage("SenderMail",Email);
mail.IsBodyHtml = true;
mail.Subject = "An email from Office365";
mail.Body = "<html><body><h1>Hello world</h1></body></html>";
SmtpClient client = new SmtpClient("smtp.office365.com");
client.Port = 587;
client.EnableSsl = true;
client.UseDefaultCredentials = false; // Important: This line of code must be executed before setting the NetworkCredentials object, otherwise the setting will be reset (a bug in .NET)
NetworkCredential cred = new System.Net.NetworkCredential("Sendermail", "Password");
client.Credentials = cred;
client.Send(mail);