You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

  1. using JMETxnPushScheduler.Repository;
  2. using System;
  3. using System.Data;
  4. namespace JMETxnPushScheduler.Business
  5. {
  6. public class SendEmail
  7. {
  8. SendRepository _repository = new SendRepository();
  9. public void mailsend()
  10. {
  11. int i = 1;
  12. DataTable mailDetails = _repository.GetMailDetails();
  13. string msgSubject = "About pasword Reset";
  14. string msgBody = string.Empty;
  15. if (mailDetails == null )
  16. {
  17. return;
  18. }
  19. else if (mailDetails.Rows.Count == 0)
  20. {
  21. return;
  22. }
  23. try
  24. {
  25. msgBody = "<html><head><meta content=text/html; charset=utf-8 http-equiv=Content-Type></head><body><table>" +
  26. "<tr><td><b>SNo.&nbsp;</b></td>" +
  27. "<td><b>Full Name</b></td>" +
  28. "<td><b>Email</b></td>" +
  29. "<td><b>User Name</b></td>" +
  30. "<td><b>New Password</b></td>" +
  31. "</tr>";
  32. foreach (DataRow item in mailDetails.Rows)
  33. {
  34. msgBody += "<tr><td>" + Convert.ToString(i ) + "</td>";
  35. msgBody += "<td>" + item["Name"].ToString() + "</td>";
  36. msgBody += "<td>" + item["Email"].ToString() + "</td>";
  37. msgBody += "<td>" + item["UserName"].ToString() + "</td>";
  38. msgBody += "<td>" + item["Newpassword"].ToString() + "</td>";
  39. i = i + 1;
  40. }
  41. msgBody += "</table></body></html>";
  42. SmtpMailSetting mail = new SmtpMailSetting
  43. {
  44. MsgBody = msgBody,
  45. MsgSubject = msgSubject,
  46. ToEmails = GetStatic.ReadWebConfig("recivermail", "")
  47. };
  48. string res = mail.SendSmtpMail(mail);
  49. //if (res != "Mail Send")
  50. //{
  51. // ErrorEmail();
  52. //}
  53. }
  54. catch (Exception ex)
  55. {
  56. ex.Message.ToString();
  57. }
  58. }
  59. public void ErrorEmail()
  60. {
  61. _repository.ErrorEmail();
  62. }
  63. }
  64. }