Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. I tried all emails but it is not working.
  2.  
  3. **HomeController.cs**
  4. [HttpPost]
  5. public ActionResult Contact(Registration reg)
  6. {
  7. if (ModelState.IsValid)
  8. {
  9. WebMail.Send(""
  10. , reg.Name + "is",
  11. reg.Message + "<br></br> My Number : "+reg.Mobile+
  12. "<br></br> My email is " +reg.Email
  13. ,null
  14. ,null
  15. ,null
  16. ,true
  17. ,null
  18. ,null
  19. ,null
  20. ,null
  21. ,null
  22. ,reg.Email);
  23. }
  24.  
  25. return View();
  26. }
  27.  
  28. **Web.config**
  29. <system.net>
  30. <mailSettings>
  31. <smtp>
  32. <network host="smtp.gmail.com"
  33. port="587"
  34. userName=""
  35. password=""
  36. enableSsl="true"
  37. />
  38. </smtp>
  39. </mailSettings>
  40. </system.net>
  41.  
  42. **Contact.cshtml**
  43. @using (Html.BeginForm())
  44. {
  45. <p>Name: @Html.TextBoxFor(model => model.Name)</p>
  46. <p>Email: @Html.TextBoxFor(model => model.Email)</p>
  47. <p>Mobile: @Html.TextBoxFor(model => model.Mobile)</p>
  48. <p>Message:</p>
  49. <p>@Html.TextAreaFor(model => model.Message)</p>
  50. <p>
  51. <input type="submit" value="Submit" />
  52. </p>
  53. }
  54.  
  55. even though i put all email, it was not working.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement