Exemple #1
0
 public static void SendMailAsync(this EmailMessageEntity email)
 {
     using (OperationLogic.AllowSave <EmailMessageEntity>())
     {
         email.State = EmailMessageState.ReadyToSend;
         email.Save();
     }
 }
Exemple #2
0
        public virtual void Send(EmailMessageEntity email)
        {
            using (OperationLogic.AllowSave <EmailMessageEntity>())
            {
                if (!EmailLogic.Configuration.SendEmails)
                {
                    email.State = EmailMessageState.Sent;
                    email.Sent  = TimeZoneManager.Now;
                    email.Save();
                    return;
                }

                try
                {
                    SendInternal(email);

                    email.State = EmailMessageState.Sent;
                    email.Sent  = TimeZoneManager.Now;
                    email.Save();
                }
                catch (Exception ex)
                {
                    if (Transaction.InTestTransaction) //Transaction.IsTestTransaction
                    {
                        throw;
                    }

                    var exLog = ex.LogException().ToLite();

                    try
                    {
                        using (Transaction tr = Transaction.ForceNew())
                        {
                            email.Exception = exLog;
                            email.State     = EmailMessageState.SentException;
                            email.Save();
                            tr.Commit();
                        }
                    }
                    catch { } //error updating state for email

                    throw;
                }
            }
        }