Esempio n. 1
0
 public void Post([FromBody] Mail mail)
 {
     try
     {
         ValidateLogin(mail);
         var mailRepository = new MailRepository();
         mailRepository.Update(mail);
     }
     catch (Exception e)
     {
         logger.Error(string.Format("Hata=>{0} StackTrace=>{1}", e.Message, e.StackTrace));
     }
 }
Esempio n. 2
0
        public void SendSmtpEmail(Mail[] mails)
        {
            int count = 1;

            foreach (Mail mail in mails)
            {
                if (mail.sender?.emailAddress == null)
                {
                    Library.WriteLine("Sender incorrect.");
                }
                Library.WriteLine("Creando email " + count++ + " de " + mails.Count());
                if (mail.sender != null)
                {
                    Library.WriteLine("Emisor: " + mail.sender.emailAddress + "------- Receptor/es: " + mail.recipients);
                    _smtp = new SMTP();
                    string[]      recipients = mail.recipients.Split(',');
                    List <String> destList   = new List <string>();
                    if (recipients?.Length > 1)
                    {
                        destList = recipients.ToList();
                    }
                    else
                    {
                        destList.Add(recipients[0]);
                    }

                    Library.WriteLine("Enviando email...");
                    Boolean result = false;
                    try
                    {
                        result = _smtp.SendHtmlEmail(
                            destList, null, mail.Subject,
                            mail.sender.emailAddress, mail.sender.name,
                            mail.body
                            );
                    }
                    catch (Exception ex)
                    {
                        Library.WriteErrorLog(ex);
                    }

                    if (result)
                    {
                        Library.WriteLine("Email Enviado. Actualizando Base de Datos.");
                        _repo.Update(mail);
                        Library.WriteLine("Base de datos Actualizada.");
                    }
                }
            }
        }