public object SendMessage(SendMailVM message) { try { EmailService.SendEmails(message); return(new ResponseVM(RequestTypeEnumVM.Success, Token.Success)); } catch (Exception ex) { return(new ResponseVM(RequestTypeEnumVM.Error, Token.SomeErrorInServer, ex)); } }
internal static void SendEmails(SendMailVM message) { var smtp = new SmtpClient(ConfigService.HostMail); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(ConfigService.BaseEmail, ConfigService.BaseEmailPassword); MailMessage msg = new MailMessage(); msg.From = new MailAddress(ConfigService.BaseEmail, Token.AppName); message.Emails.ForEach(c => msg.To.Add(new MailAddress(c))); msg.Subject = message.Subject; msg.BodyEncoding = Encoding.UTF8; msg.IsBodyHtml = true; msg.Body = message.Message; smtp.Send(msg); msg.Dispose(); }
public IActionResult Contact(SendMailVM sendMailVM) { _emailSender.SendEmailAsync(sendMailVM.FromEmail, "contact pagina", sendMailVM.Message); return(View()); }
public JsonResult SendMessage(SendMailVM obj) { return(Json(EmailsSubscriptionData.SendMessage(obj), JsonRequestBehavior.AllowGet)); }