示例#1
0
 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));
     }
 }
示例#2
0
        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();
        }
示例#3
0
 public IActionResult Contact(SendMailVM sendMailVM)
 {
     _emailSender.SendEmailAsync(sendMailVM.FromEmail, "contact pagina", sendMailVM.Message);
     return(View());
 }
示例#4
0
 public JsonResult SendMessage(SendMailVM obj)
 {
     return(Json(EmailsSubscriptionData.SendMessage(obj), JsonRequestBehavior.AllowGet));
 }