public JsonResult SendEmailFromContactUs(string senderEmail, string senderName, string subject, string content) { var result = new Com.BudgetMetal.ViewModels.VmGenericServiceResult(); try { SendingMail sm = new SendingMail(); string email = _appSettings.App_Identity.fromMail; string emailSubject = "Message From Contact Page"; string emailBody = ""; emailBody = "From : " + senderEmail + "<br>"; emailBody = emailBody + "Name : " + senderName + "<br>"; emailBody = emailBody + "Subject : " + subject + "<br><br>"; emailBody = emailBody + "Body : <br><br>" + content.Replace("\n", "<br>") + "<br>"; sm.SendMail(email, "", emailSubject, emailBody); result.IsSuccess = true; result.MessageToUser = "******"; } catch { result.IsSuccess = false; result.MessageToUser = "******"; } return(new JsonResult(result, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); }
public IActionResult DeletePointsOfInterest(int cityId, int id) { var city = CitiesDataStore.Current.Cities.FirstOrDefault(c => c.Id == cityId); if (city == null) { return(NotFound()); } var pointOfInterestFromDataStore = city.PointsOfInterest.FirstOrDefault(c => c.Id == id); if (pointOfInterestFromDataStore == null) { return(NotFound()); } var prfevCount = city.PointsOfInterest.Count; var x = city.PointsOfInterest.Remove(pointOfInterestFromDataStore); var postCount = city.PointsOfInterest.Count; IDataRepository database = new MongoDbRepository(); var mailingService = new SendingMail(database); mailingService.Send("deleted pointsOfInterest", $"pointOfInterest {pointOfInterestFromDataStore.Name} with id {pointOfInterestFromDataStore.Id} Was deleted.", "*****@*****.**", "jain99shwe@gmailcom"); return(new JsonResult(pointOfInterestFromDataStore)); }
public async Task <JsonResult> ResetPassword(string Username) { var result = await userService.ResetPassword(Username); if (result.IsSuccess) { string[] arrResponseText = result.MessageToUser.Split(",#,"); string email = arrResponseText[0]; string parameter = arrResponseText[1]; string filePath = "wwwroot/Template/"; FileStream fileStream = new FileStream(filePath + "resetpassword.htm", FileMode.Open); string msgBody = ""; using (StreamReader reader = new StreamReader(fileStream)) { string line = reader.ReadToEnd(); msgBody = msgBody + line; } msgBody = msgBody.Replace("[parameter]", parameter); SendingMail sm = new SendingMail(); sm.SendMail(email, "", "Reset Password", msgBody); result.MessageToUser = email; } return(new JsonResult(result, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); }
public async Task <IActionResult> Index(VmUserItem user) { string[] serviceTags; serviceTags = Request.Form["serviceTags"].ToArray(); var result = await userService.Register(user, serviceTags); if (result.IsSuccess) { string mailBody = ""; string confirmationLink = ""; //var location = new Uri($"{Request.Scheme}://{Request.Host}{Request.Path}{Request.QueryString}"); var location = new Uri($"{Request.Scheme}://{Request.Host}"); var url = location.AbsoluteUri; string encodeEmail = user.EmailAddress.EncodeString(); // Convert.ToBase64String(Encoding.UTF8.GetBytes(user.EmailAddress)); string token = _appSettings.App_Identity.Identity; //var byte_time = Encoding.UTF8.GetBytes(DateTime.Now.AddDays(2).ToString()); string encodeTimeLimit = DateTime.Now.AddDays(2).ToString().EncodeString(); // Convert.ToBase64String(byte_time); confirmationLink = url + "Registration/ConfirmUser?token=" + token + "&e=" + encodeEmail + "&t=" + encodeTimeLimit; mailBody = "Please confirm your account by clicking the following link \n " + confirmationLink; SendingMail sm = new SendingMail(); sm.SendMail(user.EmailAddress, "", "Confirmation for Registration", mailBody); return(RedirectToAction("SuccessRegistration")); } else { return(View()); } }
public async Task <IActionResult> Register(RegisterViewModel model) { User user; if (ModelState.IsValid) { if (model.Gender == 0) { user = new User { FirstName = model.FistName, LastName = model.LastName, UserName = model.Email, Email = model.Email, UserState = UserState.notblocked, BirthDate = new DateTime(model.Year, model.Month, model.Day), Gender = model.Gender, ProfilePic = "Male_avater.jpg" }; } else { user = new User { FirstName = model.FistName, LastName = model.LastName, UserName = model.Email, Email = model.Email, UserState = UserState.notblocked, BirthDate = new DateTime(model.Year, model.Month, model.Day), Gender = model.Gender, ProfilePic = "Female_avater.jpg" }; } await userManager.AddToRoleAsync(user, "User"); var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { var token = await userManager.GenerateEmailConfirmationTokenAsync(user); var confirmationLink = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, token = token }, Request.Scheme); //Sending Comfirmation Mail To the User SendingMail.Send(confirmationLink, user.Email); ViewBag.WarningTitle = "Registration Successful"; ViewBag.WarningMessage = "Before you can Login, please confirm your email, by clicking on the confirmation link we have emailed you"; return(View("SuccessfulRegistration")); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View()); }
public ActionResult Mail(EmailSettings settings) { if (ModelState.IsValid) { SendingMail.SendEmail(settings); return(View("Sent")); } return(View(settings)); }
public async void postFeedback(MailModel model) { MailModel mail = new MailModel(); mail.Name = model.Name; mail.Email = model.Email; mail.Feed = model.Feed; mail.Subject = model.Subject; mail.Date = model.Date; SendingMail sendingMail = new SendingMail(mail); await sendingMail.sendEmail(); }
public ActionResult Pay(Invoice model, List <string> PaymentTypes) { model.PaymentDate = DateTime.Now; foreach (string item in PaymentTypes) { int PaymentId = Convert.ToInt32(item); model.PaymentTypeId = PaymentId; } model.OrderId = ((Order)Session["Order"]).OrderId; InvoiceRepository ip = new InvoiceRepository(); if (ip.Insert(model).IsSucceeded) { Order ord = (Order)Session["Order"]; OrderRepository ordrep = new OrderRepository(); ord.IsPay = true; int id = Convert.ToInt32(HttpContext.Request.Cookies["UserId"].Value); ord.MemberId = id; ordrep.Update(ord); MemberRepository mr = new MemberRepository(); model.Order.Member = mr.GetObjById(id).ProcessResult; model.Order.MemberId = ord.MemberId; ViewData["model"] = model; var body = GetEmailTemplate(); body.Replace("C2", "C2"); SendingMail SendMail = new SendingMail(); if (SendMail.sendMail(model.Order.Member.FirstName, model.Order.Member.LastName, model.Order.Member.Email, body, model.Order.OrderId)) { ViewBag.Mesaj = "Message delivered"; } else { ViewBag.Mesaj = "Message not delivered"; } Session.Abandon(); return(RedirectToAction("ListAllProduct", "Home")); } else { return(View(model)); } }
public async Task <JsonResult> ResetPassword(string Email) { string newPassword = CreateRandomPassword(6); var result = await userService.ResetPassword(Email, newPassword); if (result.IsSuccess) { string mailBody = ""; mailBody = "Your new password for EzyTender is " + newPassword; SendingMail sm = new SendingMail(); sm.SendMail(Email, "", "Reset Password", mailBody); } return(new JsonResult(result, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); }
public void Adding_New_City_Sends_An_Email() { //test setup var inMemoryRepo = new InMemoryDataRepositoy(); var mailingService = new SendingMail(inMemoryRepo); int initialCount = inMemoryRepo.Count(); // test service mailingService.Send( "Diwali Vacation", "I will be on vacation for next two weeks", "*****@*****.**", "*****@*****.**"); // assert Assert.AreEqual(initialCount + 1, inMemoryRepo.Count()); }
private async void AlertOpenRFQForExpiring() { var rfqList = await repoRFQ.GetAllOpenRFQ(); if (rfqList != null) { foreach (var item in rfqList) { if (Convert.ToDateTime(item.ValidRfqdate).Date < DateTime.Now.Date) { //send email var documentUser = item.Document.DocumentUser.Where(e => e.IsActive == true).OrderBy(e => e.Id).First(); var ownerId = documentUser.User_Id; var user = await repoUser.Get(ownerId); SendingMail SM = new SendingMail(); SM.SendMail(user.EmailAddress, "", "Alert Test", "Testing"); } } } }
public ActionResult SignUp(student e) { if (!ModelState.IsValid) { return(View()); } e.status = 0; e.img = "student"; var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var stringCharsuser = new char[6]; var stringCharspass = new char[8]; var random = new Random(); for (int i = 0; i < stringCharsuser.Length; i++) { stringCharsuser[i] = chars[random.Next(chars.Length)]; } for (int i = 0; i < stringCharspass.Length; i++) { stringCharspass[i] = chars[random.Next(chars.Length)]; } e.Id = new String(stringCharsuser); e.pw = new String(stringCharspass); db.students.InsertOnSubmit(e); db.SubmitChanges(); string a = SendingMail.sendMail(new SendingMail { To = e.email, Subject = "Here your first time login activation ! ", Message = "Temporary username: "******"\n Temporary password" + e.pw }); ViewBag.msn = a; ViewBag.accept = "Registered successfully ! We sent an E-Mail for ur activation infos..."; return(View()); }