public String ForgotPassword(ForgotPasswordBindingModel model) { String Subject = "Mini-CRM Password Reset Token"; if (!ModelState.IsValid) { return("Invalid Request"); } var user = _adminLog.GetByEmail(model.Email); if (user == null) { return("Sorry! No record is linked to that Email."); } String Passwordtoken = RandomPassword(); //Creating a SMTP client to send/receive emails SmtpClient client = new SmtpClient("smtp.gmail.com"); client.Host = "smtp.gmail.com"; client.Port = 587; client.EnableSsl = true; client.UseDefaultCredentials = false; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "det@1234567@9"); MailMessage message = new MailMessage(); message.From = new MailAddress("*****@*****.**", "Jay Joshi"); message.To.Add(new MailAddress(model.Email, "Jay Joshi")); message.Subject = Subject; message.Body = Passwordtoken; message.BodyEncoding = UTF8Encoding.UTF8; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(message); return("Mail has been sent with a code to reset your password."); }