public ActionResult ResetPassword(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { return(View()); } else { using (LIVEDBEntities6 db = new LIVEDBEntities6()) { var user = db.HC_USERS.Where(a => a.RID == model.id).FirstOrDefault(); if (user != null) { user.pswd = model.ConfirmPassword; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "New password updated successfully"; ViewBag.Message = message; return(View("Login")); } else { message = "Something invalid"; ViewBag.Message = message; return(View()); } } } }
public ActionResult ForgotPassword1(string email) { //Verify Email ID //Generate Reset password link //Send Email string message = ""; bool status = false; using (LIVEDBEntities6 db = new LIVEDBEntities6()) { var account = db.HC_USERS.Where(a => a.EmailID == email).FirstOrDefault(); if (account != null) { //Send email for reset password //string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(account.EmailID, account.RID, "ResetPassword"); //account.UserName = resetCode; //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property //in our model class in part 1 db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "Reset password link has been sent to your email id."; } else { message = "Account not found"; } } ViewBag.Message = message; return(View("ForgotPassword")); }
public string mail(hc_client_user obj, string EmailSubject = null, string EMailBody = null, string ToEmail = null, string EmailBCC = null, string EmailCC = null, string fileupload = null, string fileUploader = null, long country = 0) { HC_EMAIL_SENT_LOG model = new HC_EMAIL_SENT_LOG(); try { var message = new MailMessage(); var from = db.IHD_Country_EmailID.Where(x => x.CountryID == country).Select(x => x.CounEmailID).FirstOrDefault(); message.From = new MailAddress(from); // replace with valid value message.Subject = EmailSubject; message.Body = EMailBody; message.IsBodyHtml = true; var smtp = new SmtpClient { Host = "mailbrd.collabera.com", Port = 25, EnableSsl = false, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, }; if (ToEmail != null) { if (fileupload != "") { string[] filesdata = fileupload.Split(','); foreach (string item in filesdata) { Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/uploadfolder/"), item)); message.Attachments.Add(attachment); } } if (fileUploader != "") { string[] files = fileUploader.Split(','); foreach (string item in files) { var value = new WebClient(); var filepath = Path.Combine(Server.MapPath("~/uploadfolder/"), item); var filedest = Path.Combine(Server.MapPath("~/uploadeddata/"), item); value.DownloadFile(filepath, filedest); Attachment attachment = new Attachment(filepath, MimeMapping.GetMimeMapping(filepath)); message.Attachments.Add(attachment); value.Dispose(); } } message.To.Add(new MailAddress(ToEmail)); smtp.Send(message); var data = db.TimeSheetDetailsAgainstCandidate(obj.clid).ToArray(); foreach (var datainfo in data) { model.employeeno = obj.clid; model.TSStartdate = datainfo.StartDate; model.TSEnddate = datainfo.EndDate; model.TemplateId = (int)obj.tempid; model.EmailSent = DateTime.Now; model.DateEmailSentUserId = (long)Session["userid"]; db.HC_EMAIL_SENT_LOG.Add(model); db.SaveChanges(); } } if (EmailCC != null) { if (fileupload != "") { string[] filesdata = fileupload.Split(','); foreach (string item in filesdata) { Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/uploadfolder/"), item)); message.Attachments.Add(attachment); } } if (fileUploader != "") { string[] files = fileUploader.Split(','); foreach (string item in files) { var value = new WebClient(); var filepath = Path.Combine(Server.MapPath("~/uploadfolder/"), item); var filedest = Path.Combine(Server.MapPath("~/uploadeddata/"), item); //FileInfo file = new FileInfo(filedest); //file.Delete(); value.DownloadFile(filepath, filedest); Attachment attachment = new Attachment(filepath, MimeMapping.GetMimeMapping(filepath)); message.Attachments.Add(attachment); value.Dispose(); } } message.CC.Add(new MailAddress(EmailCC)); smtp.Send(message); } if (EmailBCC != null) { if (fileupload != "") { string[] filesdata = fileupload.Split(','); foreach (string item in filesdata) { Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/uploadfolder/"), item)); message.Attachments.Add(attachment); } } if (fileUploader != "") { string[] files = fileUploader.Split(','); foreach (string item in files) { var value = new WebClient(); var filepath = Path.Combine(Server.MapPath("~/uploadfolder/"), item); var filedest = Path.Combine(Server.MapPath("~/uploadeddata/"), item); value.DownloadFile(filepath, filedest); Attachment attachment = new Attachment(filepath, MimeMapping.GetMimeMapping(filepath)); message.Attachments.Add(attachment); value.Dispose(); } } message.Bcc.Add(new MailAddress(EmailBCC)); smtp.Send(message); } return("Email Send."); } catch (Exception ex) { string ip = Request.UserHostAddress; errorfile.SendErrorToText(ex, ip); return("Problem while sending email, Please check details."); } }