Guest User

Untitled

a guest
May 28th, 2018
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. <form id="PrintForm">
  2. <input type="text" id="txtEmail" />
  3.  
  4. <input type="submit" value="Send" />
  5. </form> <br>
  6.  
  7. <form id="CloudForm">
  8. <input type="text" id="txtEmail" />
  9.  
  10. <input type="submit" value="Send" />
  11. </form>
  12.  
  13. <script>
  14. $(document).ready(function () {
  15.  
  16. $("#PrintForm").submit(function (e) {
  17.  
  18. e.preventDefault();
  19.  
  20. var email = $("#txtEmail").val();
  21.  
  22. $.ajax({
  23. type: 'POST',
  24. url: "/xxx/AjaxMethod",
  25. dataType: 'json',
  26. data: {
  27. email: email,
  28. },
  29. success: function (status) {
  30. console.log('Send');
  31. },
  32. error: function () {
  33. console.log('something went wrong - debug it!');
  34. }
  35. });
  36.  
  37. });
  38.  
  39.  
  40. });
  41. </script><br>
  42.  
  43. [HttpPost]
  44. public JsonResult AjaxMethod(string email)
  45. {
  46.  
  47. var SubjectOne = "Print";
  48. var SendToPrint = "Print@Print.com";
  49.  
  50. var errorMessage = "";
  51.  
  52. //BookingViewModel
  53. Booking book = new Booking {
  54. Email = email,
  55. };
  56.  
  57.  
  58. try
  59. {
  60. // Initialize WebMail helper
  61. WebMail.SmtpServer = "smtp";
  62. WebMail.SmtpPort = 25;
  63. WebMail.UserName = "email@email.com";
  64. WebMail.Password = "";
  65. WebMail.From = "email@email.com";
  66. WebMail.EnableSsl = true;
  67. WebMail.SmtpUseDefaultCredentials = false;
  68.  
  69.  
  70. // Send email
  71. WebMail.Send(to: SendToPrint,
  72. subject: SubjectOne,
  73. body: "email: " + email + "<br>"
  74. );
  75.  
  76. }
  77. catch (Exception ex)
  78. {
  79. errorMessage = ex.Message;
  80. }
  81.  
  82. return Json(book);
  83.  
  84. }
Add Comment
Please, Sign In to add comment