Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. public ActionResult SendMails()
  2. {
  3. GMailer.GmailUsername = "panmail1212p@gmail.com";
  4. GMailer.GmailPassword = "zaq1@wsx";
  5.  
  6. AccountVM acc = new AccountVM();
  7. BorrowingVM vm = new BorrowingVM();
  8. var licznik1 = 0;
  9. GMailer mailer = new GMailer();
  10. foreach (var a in vm.Get_list())
  11. {
  12. if(a.Returned==false)
  13. {
  14. if(a.Return_date<DateTime.Now)
  15. {
  16. foreach(var b in acc.Get_list())
  17. {
  18. if(b.AccountID==a.ReaderID)
  19. {
  20. licznik1++;
  21. mailer.ToEmail = b.Email;
  22. mailer.Subject = "Zwrot";
  23. mailer.Body = "Prosimy o zwrot książki!";
  24. mailer.IsHtml = true;
  25. mailer.Send();
  26. break;
  27. }
  28. }
  29. }
  30. }
  31. }
  32. ViewBag.Mails1 ="Wysłano próśb " +licznik1;
  33.  
  34. var licznik2 = 0;
  35. foreach (var a in vm.Get_list())
  36. {
  37. if (a.Returned == false)
  38. {
  39. if (a.Return_date.Date==DateTime.Now.Date.AddDays(1))
  40. {
  41. foreach (var b in acc.Get_list())
  42. {
  43. if (b.AccountID == a.ReaderID)
  44. {
  45. licznik2++;
  46. mailer.ToEmail = b.Email;
  47. mailer.Subject = "Przypomnienie";
  48. mailer.Body = "Został Tobie dzień na zwrot książki!";
  49. mailer.IsHtml = true;
  50. mailer.Send();
  51. }
  52. }
  53. }
  54. }
  55. }
  56. ViewBag.Mails2 ="Wysłano przypomnień "+ licznik2;
  57.  
  58.  
  59. return View("Admin");
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement