Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult sendMail()
- {
- string mail = (Request["mail"]);
- string body = Request["body"];
- if (mail == null) return null;
- USER_UD user = null;
- user = USER_UDRepo.GetByUsername(mail);
- ResultData result = new ResultData();
- if (user == null) { result.ERR_CODE = 1;
- result.Message = "Không tìm thấy tài khoản người dùng trong cơ sở dữ liệu.";
- goto Done;
- }
- else result.ERR_CODE = 0;
- result.DATA = user;
- var fromAddress = new MailAddress("kmavnteam@gmail.com", "Bệnh Viện Phụ Sản Hà Nội");
- var toAddress = new MailAddress(mail, "");
- const string subject = "Bệnh Viện Phụ Sản Hà Nội";
- var smtp = new SmtpClient
- {
- Host = "smtp.gmail.com",
- Port = 587,
- EnableSsl = true,
- DeliveryMethod = SmtpDeliveryMethod.Network,
- UseDefaultCredentials = false,
- Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
- };
- using (var message = new MailMessage(fromAddress, toAddress)
- {
- Subject = subject,
- Body = body
- })
- {
- smtp.Send(message);
- }
- Done:
- return Json(result, JsonRequestBehavior.AllowGet);
- }
- public ActionResult changePass()
- {
- int u_id = int.Parse(Request["id"]);
- ResultData result = new ResultData();
- result.ERR_CODE = 1;
- USER_UD userUd = USER_UDRepo.GetByID(u_id);
- if (userUd != null) {
- userUd.password = Request["pass"].Password();
- USER_UDRepo.Save(userUd);
- result.ERR_CODE = 0;
- }
- result.Message = "Cập nhật thông tin thành công";
- return Json(result, JsonRequestBehavior.AllowGet);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement