Hello
Can you show me how i can send email from a FrontEnd page using EmailSender.
Thanks
Anwar
6 Answer(s)
-
0
Can you please check help me out here i need to send email from front end pages
-
0
Hi @avanekar02,
You just need to do it like we do for admin site. Have you tried it ?
Thanks.
-
0
can you pint me to a page, please
-
0
Hi,
You just need to inject IEmailSender to your controller and send email using it. You can check UserEmailer for it's usage.
Thanks.
-
0
this is the error i get
HTTP Error 400.0 - Empty or invalid anti forgery header token. shown below is cshtml and controller file
This is my form feedback.cshtml
@using Samit.CmsProTest.Web.Navigation
@{ ViewBag.CurrentPageName = PageNames.Frontend.FeedBack; }
<div class="row"> <div class="col-md-12 page-404"> <div class="number font-red"> @L("FeedBack") </div> <div class="details" style="width:40%"> <form class="feedback-form" action="@Url.Action("FeedBack")" method="post">
<div class="form-group"> <label class="control-label visible-ie8 visible-ie9">@L("Name")</label> <input class="form-control placeholder-no-fix" type="text" placeholder="@L("Name")" name="Name" required value="@Model.Name" maxlength="@Samit.CmsProTest.Authorization.Users.User.MaxNameLength" /> </div> <div class="form-group"> <label class="control-label visible-ie8 visible-ie9">@L("EmailAddress")</label> <input class="form-control placeholder-no-fix" type="email" placeholder="@L("EmailAddress")" name="EmailAddress" required value="@Model.EmailAddress" maxlength="@Samit.CmsProTest.Authorization.Users.User.MaxEmailAddressLength" /> </div> <div class="form-group "> <label class="control-label visible-ie8 visible-ie9">@L("FeedBack")</label> <textarea class="form-control" rows="5" placeholder="@L("FeedBack")" name="Suggestions" required value="@Model.Suggestions"></textarea> </div> <div class="form-actions"> <a href="@Url.Action("Index", "FeedBack")"> </a> <button type="submit" class="btn btn-success uppercase pull-right">@L("Submit")</button> </div> </form> </div> </div>
</div>
FeedBackController
using Abp.Domain.Uow; using Samit.CmsProTest.School.Courses; using Samit.CmsProTest.School.Courses.Dto; using Samit.CmsProTest.Web.Models; using Samit.CmsProTest.Web.Models.FeedBack; using System.Web.Mvc;
namespace Samit.CmsProTest.Web.Controllers { public class FeedBackController : CmsProTestControllerBase { private readonly ICourseDtlAppService _courseDtlAppService;
public FeedBackController(ICourseDtlAppService courseDtlAppService) { _courseDtlAppService = courseDtlAppService; } public ActionResult Index(FeedBackViewModel feedbackViewModel) { var model = new FeedBackViewModel(); return View(model); } [HttpPost] [UnitOfWork] public ActionResult FeedBack(FeedBackViewModel feedBackModel) { var model = new FeedBackViewModel(); return View(model); } }
}
-
0
Hi,
You can do two things.
- Disable anti forgery token validation by adding [DisableAbpAntiForgeryTokenValidation] attribute to your action.
- add below line to your frontend razor view
@{ SetAntiForgeryCookie(); }
Thanks.