public async Task <IActionResult> AddEmail(EmailSendViewModel e) { ViewBag.Addresses = _inventoryService.GetAllInventories(); if (e.Quatity < _inventoryService.GetById(e.InventoriesId).Quantity) { using (var smtp = new SmtpClient()) { smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtp.PickupDirectoryLocation = @"D:\MyMail\ticket_order"; var a = _inventoryService.GetById(e.InventoriesId).FullAd; var msg = new MailMessage { Body = e.Name + " " + e.Email + " " + e.Phone + " " + e.Quatity + " " + a, Subject = "Order", From = new MailAddress("*****@*****.**") }; msg.To.Add("*****@*****.**"); await smtp.SendMailAsync(msg); } string content = "Có phải bạn muốn mua" + _inventoryService.GetById(e.InventoriesId).FullAdv + e.Quatity; string image = _inventoryService.GetById(e.InventoriesId).Image; new MailHelper().SendMail(e.Email, "Tin nhắn từ Evennet", content, image); var info = System.Globalization.CultureInfo.GetCultureInfo("vi-VN"); TempData["Message"] = MessageHelper.YourBidOffer + $" {e.Email} là " + String.Format(info, "{0:c} VNĐ", _inventoryService.GetById(e.InventoriesId).SalePrice.ToString("N0")); return(new JsonResult(new { success = true, responseText = "Your message successfuly sent!" })); } return(new JsonResult(new { success = false, responseText = "The attached file is not supported." })); }
public async Task <bool> EmailGonder(EmailSendViewModel model) { var result = false; var message = new MailMessage { From = new MailAddress("*****@*****.**", "Taşkesti") }; message.To.Add(model.EmailAdres ?? string.Empty); message.SubjectEncoding = Encoding.UTF8; message.BodyEncoding = Encoding.UTF8; message.Subject = $"{model.Konu}"; message.IsBodyHtml = true; message.Body = $"Merhabalar;{model.Mesaj}"; message.Priority = MailPriority.High; var smtp = new SmtpClient { Host = "smtp.gmail.com", EnableSsl = true, Credentials = new NetworkCredential("*****@*****.**", "vedatSedir2323"), DeliveryMethod = SmtpDeliveryMethod.Network, Port = 587 }; smtp.Send(message); return(true); }
public IActionResult sendMail([FromBody] EmailSendViewModel emvm) { string SmtpUrl = "smtp.office365.com"; string SmtpUN = "*****@*****.**"; string SmtpPwd = "SKF@4321"; string SenderEmailId = "*****@*****.**"; int Port = 25; bool EnableSsl = true; SmtpClient sc = new SmtpClient(SmtpUrl); NetworkCredential nc = new NetworkCredential(SmtpUN, SmtpPwd); sc.Port = Port; sc.EnableSsl = EnableSsl; sc.Credentials = nc; MailMessage msg = new MailMessage(); msg.From = new MailAddress(SenderEmailId); msg.Subject = emvm.Subject; msg.Body = emvm.Body; msg.To.Add(new MailAddress(emvm.ToMail)); //if (emvm.ToEmailList != null && emvm.ToEmailList.Count > 0) //{ // foreach (EmailsenderAttViewModel eavm in emvm.ToEmailList) // { // msg.To.Add(new MailAddress(eavm.EmailId)); // } //} //msg.to = emvm.ToEmailList sc.Send(msg); return(Ok("Success")); }
public IActionResult AddEmail() { ViewBag.Addresses = _inventoryService.GetAllInventories(); var model = new EmailSendViewModel() { employee = _context.Employees.ToList(), _mails = mails, }; return(PartialView(model)); }
public async Task <IActionResult> RealTimeTask(EmailSendViewModel e) { ViewBag.Addresses = _inventoryService.GetAllInventories(); var info = System.Globalization.CultureInfo.GetCultureInfo("vi-VN"); TempData["Message"] = MessageHelper.YourBidOffer + $" {e.Email} là " + String.Format(info, "{0:c} VNĐ", _inventoryService.GetById(e.InventoriesId).SalePrice.ToString("N0")); Inventory product = _inventoryService.GetById(e.InventoriesId); product.LuotDat += 1; await _inventoryService.UpdateAsync(product); ViewBag.SuccessMsg = "Thank you"; return(RedirectToAction("Index", "User")); }
public async Task <IActionResult> AddEmailtest(EmailSendViewModel e) { ViewBag.Addresses = _inventoryService.GetAllInventories(); if (e.Quatity <= _inventoryService.GetById(e.InventoriesId).Quantity&& e.Quatity != 0) { using (var smtp = new SmtpClient()) { smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtp.PickupDirectoryLocation = @"D:\MyMail\ticket_order"; var a = _inventoryService.GetById(e.InventoriesId).FullAd; var msg = new MailMessage { Body = e.Name + " " + e.Email + " " + e.Phone + " " + e.Quatity + " " + a, Subject = "Order", From = new MailAddress("*****@*****.**") }; msg.To.Add("*****@*****.**"); await smtp.SendMailAsync(msg); } string content = $"Có phải bạn muốn mua{_inventoryService.GetById(e.InventoriesId).FullAdv} Với số lượng là {e.Quatity} vé"; string image = _inventoryService.GetById(e.InventoriesId).Image; new MailHelper().SendMail(e.Email, "Tin nhắn từ Evennet", content, image); var info = System.Globalization.CultureInfo.GetCultureInfo("vi-VN"); TempData["Message"] = MessageHelper.YourBidOffer + $" {e.Email} là " + String.Format(info, "{0:c} VNĐ", (_inventoryService.GetById(e.InventoriesId).SalePrice *e.Quatity).ToString("N0")); var product = new Product() { Id = "p01", Name = "True", Photo = "True" }; return(new JsonResult(product)); } else { var product = new Product() { Id = "p02", Name = "False", Photo = "False" }; return(new JsonResult(product)); } }
public IActionResult Send([Bind("Email,Title,Body")] EmailSendViewModel toSend) { if (ModelState.IsValid) { // Adicionar paragrafos no corpo, caso existam if (!String.IsNullOrEmpty(toSend.Body)) { toSend.Body = toSend.Body.Replace("\n", "<br/>"); } bool success = _email.Send(toSend.Email, toSend.Title, toSend.Body); return(Json(new { success })); } return(PartialView("PartialViews/_SendForm", toSend)); }
public async Task <IActionResult> AddEmail3(EmailSendViewModel e) { using (var smtp = new SmtpClient()) { smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtp.PickupDirectoryLocation = @"D:\MyMail\event_subcribe"; var msg = new MailMessage { Body = "Tài khoản " + e._mails.From + " đã đồng ý nhận quảng cáo từ trang", Subject = "Subcribe", From = new MailAddress(e._mails.From) }; msg.To.Add("*****@*****.**"); await smtp.SendMailAsync(msg); } new MailHelper().SendMail(e.Email, "Tin nhắn từ Evennet", "Cảm ơn bạn đã nhận quảng cáo từ công ty", null); return(RedirectToAction("Index", "User")); }
public async Task <IActionResult> AddEmail2(EmailSendViewModel e) { using (var smtp = new SmtpClient()) { smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtp.PickupDirectoryLocation = @"D:\MyMail\event_contact"; var msg = new MailMessage { Body = e.Name, Subject = e._mails.Subject, From = new MailAddress(e._mails.From) }; msg.To.Add("*****@*****.**"); await smtp.SendMailAsync(msg); } new MailHelper().SendMail(e.Email, "Tin nhắn từ Evennet", "Cảm ơn bạn đã để lại thông tin liên hệ", null); return(RedirectToAction("Index", "User")); }
public IActionResult EmailSend(EmailSendViewModel model) { try { if (ModelState.IsValid) { try { EmailSendServiceModel modelService = new EmailSendServiceModel { Subject = model.Subject, Message = model.Message, }; var isEmailSent = homeService.SendEmail(modelService); if (isEmailSent) { return(RedirectToAction("EmailSuccess", "Home")); } else { return(RedirectToAction("EmailError", "Home")); } } catch (SmtpException ex) { Console.WriteLine(ex.ToString()); } } } catch (Exception) { ViewBag.Error = "Some Error"; } return(View()); }
public async Task <ActionResult> EmailGonder(EmailSendViewModel model) { var data = await emailService.EmailGonder(model); return(Json(data, JsonRequestBehavior.AllowGet)); }