/// <summary>
        /// Sends SMS
        /// </summary>
        /// <param name="text">SMS text</param>
        /// <returns>Result</returns>
        public bool SendSms(string text)
        {
            try
            {
                var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
                if (emailAccount == null)
                    emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
                if (emailAccount == null)
                    throw new Exception("No email account could be loaded");

                var queuedEmail = new QueuedEmail()
                {
                    Priority = 5,
                    From = emailAccount.Email,
                    FromName = emailAccount.DisplayName,
                    To = _verizonSettings.Email,
                    ToName = string.Empty,
                    Subject = _storeContext.CurrentStore.Name,
                    Body = text,
                    CreatedOnUtc = DateTime.UtcNow,
                    EmailAccountId = emailAccount.Id
                };

                _queuedEmailService.InsertQueuedEmail(queuedEmail);

                return true;
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
                return false;
            }
        }
        public void Can_save_and_load_queuedEmail()
        {
            var qe = new QueuedEmail
            {
                PriorityId = 5,
                From = "From",
                FromName = "FromName",
                To = "To",
                ToName = "ToName",
                ReplyTo = "ReplyTo",
                ReplyToName = "ReplyToName",
                CC = "CC",
                Bcc = "Bcc",
                Subject = "Subject",
                Body = "Body",
                AttachmentFilePath = "some file path",
                AttachmentFileName = "some file name",
                AttachedDownloadId = 3,
                CreatedOnUtc = new DateTime(2010, 01, 01),
                SentTries = 5,
                SentOnUtc = new DateTime(2010, 02, 02),
                DontSendBeforeDateUtc = new DateTime(2016, 2 , 23),
                EmailAccount = new EmailAccount
                {
                    Email = "*****@*****.**",
                    DisplayName = "Administrator",
                    Host = "127.0.0.1",
                    Port = 125,
                    Username = "******",
                    Password = "******",
                    EnableSsl = true,
                    UseDefaultCredentials = true
                }

            };

            var fromDb = SaveAndLoadEntity(qe);
            fromDb.ShouldNotBeNull();
            fromDb.PriorityId.ShouldEqual(5);
            fromDb.From.ShouldEqual("From");
            fromDb.FromName.ShouldEqual("FromName");
            fromDb.To.ShouldEqual("To");
            fromDb.ToName.ShouldEqual("ToName");
            fromDb.ReplyTo.ShouldEqual("ReplyTo");
            fromDb.ReplyToName.ShouldEqual("ReplyToName");
            fromDb.CC.ShouldEqual("CC");
            fromDb.Bcc.ShouldEqual("Bcc");
            fromDb.Subject.ShouldEqual("Subject");
            fromDb.Body.ShouldEqual("Body");
            fromDb.AttachmentFilePath.ShouldEqual("some file path");
            fromDb.AttachmentFileName.ShouldEqual("some file name");
            fromDb.AttachedDownloadId.ShouldEqual(3);
            fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
            fromDb.SentTries.ShouldEqual(5);
            fromDb.SentOnUtc.ShouldNotBeNull();
            fromDb.SentOnUtc.Value.ShouldEqual(new DateTime(2010, 02, 02));
            fromDb.DontSendBeforeDateUtc.ShouldEqual(new DateTime(2016, 2, 23));
            fromDb.EmailAccount.ShouldNotBeNull();
            fromDb.EmailAccount.DisplayName.ShouldEqual("Administrator");
        }
        private int SendNotification(MessageTemplate messageTemplate, 
            EmailAccount emailAccount, int languageId, IEnumerable<Token> tokens,
            string toEmailAddress, string toName)
        {
            //retrieve localized message template data
            var bcc = messageTemplate.GetLocalized((mt) => mt.BccEmailAddresses, languageId);
            var subject = messageTemplate.GetLocalized((mt) => mt.Subject, languageId);
            var body = messageTemplate.GetLocalized((mt) => mt.Body, languageId);

            //Replace subject and body tokens 
            var subjectReplaced = _tokenizer.Replace(subject, tokens, false);
            var bodyReplaced = _tokenizer.Replace(body, tokens, true);
            
            var email = new QueuedEmail()
            {
                Priority = 5,
                From = emailAccount.Email,
                FromName = emailAccount.DisplayName,
                To = toEmailAddress,
                ToName = toName,
                CC = string.Empty,
                Bcc = bcc,
                Subject = subjectReplaced,
                Body = bodyReplaced,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = emailAccount.Id
            };

            _queuedEmailService.InsertQueuedEmail(email);
            return email.Id;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deleted a queued email
        /// </summary>
        /// <param name="queuedEmail">Queued email</param>
        public virtual void DeleteQueuedEmail(QueuedEmail queuedEmail)
        {
            if (queuedEmail == null)
                throw new ArgumentNullException("queuedEmail");

            _queuedEmailRepository.Delete(queuedEmail);

            //event notification
            _eventPublisher.EntityDeleted(queuedEmail);
        }
        public void Can_save_and_load_queuedEmail()
        {
            var qe = new QueuedEmail()
            {
                Priority = 1,
                From = "From",
                FromName = "FromName",
                To = "To",
                ToName = "ToName",
                CC = "CC",
                Bcc = "Bcc",
                Subject = "Subject",
                Body = "Body",
                CreatedOnUtc = new DateTime(2010, 01, 01),
                SentTries = 5,
                SentOnUtc = new DateTime(2010, 02, 02),
                EmailAccount = new EmailAccount
                {
                    Email = "*****@*****.**",
                    DisplayName = "Administrator",
                    Host = "127.0.0.1",
                    Port = 125,
                    Username = "******",
                    Password = "******",
                    EnableSsl = true,
                    UseDefaultCredentials = true
                }

            };

            var fromDb = SaveAndLoadEntity(qe);
            fromDb.ShouldNotBeNull();
            fromDb.Priority.ShouldEqual(1);
            fromDb.From.ShouldEqual("From");
            fromDb.FromName.ShouldEqual("FromName");
            fromDb.To.ShouldEqual("To");
            fromDb.ToName.ShouldEqual("ToName");
            fromDb.CC.ShouldEqual("CC");
            fromDb.Bcc.ShouldEqual("Bcc");
            fromDb.Subject.ShouldEqual("Subject");
            fromDb.Body.ShouldEqual("Body");
            fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
            fromDb.SentTries.ShouldEqual(5);
            fromDb.SentOnUtc.Value.ShouldEqual(new DateTime(2010, 02, 02));

            fromDb.EmailAccount.ShouldNotBeNull();
            fromDb.EmailAccount.DisplayName.ShouldEqual("Administrator");
        }
        private void EmailOperationsManager(string emailSubject)
        {
            //***************************************************************************************************************
            //* Get the people with roles of Operations Manager so you can email them
            //***************************************************************************************************************
            int omRoleId = _consignorService.GetIdForRole("OperationsManager");
            int[] customerRoleIds = new int[1];

            if (omRoleId != 0)
            {
                customerRoleIds[0] = omRoleId;
            }
            else
            {
                customerRoleIds[0] = 0;  //CustomerRole table begins with 1
                _logger.Warning(string.Format("ApplyMaximums Task could not find a Customer with Operations Manager Role to email results at {0} (UTC {1})",
                    DateTime.Now, DateTime.UtcNow));
                return;
            }

            //this will only find customers with the Operations Manager role
            var omCustomers = _customerService.GetAllCustomers(
                    customerRoleIds: customerRoleIds,
                    pageIndex: 0,
                    pageSize: 500);


            var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
            if (emailAccount == null)
                emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
            if (emailAccount == null)
            {
                _logger.Warning(string.Format("ApplyMaximums Task  could not find an email account to email notifications at {0} (UTC {1})",
                    DateTime.Now, DateTime.UtcNow));
                return;
            }

            //************************************************************************************************************
            //* GET THE EMAILACCOUNT TO USE
            //***********************************************************************************************************

            var email = new QueuedEmail
               {
                   Priority = QueuedEmailPriority.High,
                   EmailAccountId = emailAccount.Id,
                   FromName = emailAccount.DisplayName,
                   From = emailAccount.Email,
               };


            if (emailAccount != null)  //can only send emails if an smtp account is set up
            {
                foreach (var c in omCustomers)  //send sale awarded email to all Operations Managers
                {
                    try
                    {
                        if (String.IsNullOrWhiteSpace(c.Email))
                            _logger.Warning(string.Format("ApplyMaximums Task Operations Manager does not have an email to send ApplyMaximums fatal notification - customer id: {0} at {1} (UTC {2})",
                                c.Id, DateTime.Now, DateTime.UtcNow));
                        if (!CommonHelper.IsValidEmail(c.Email))
                            _logger.Warning(string.Format("ApplyMaximums Task Operations Manager does not have a valid email to send ApplyMaximums fatal notification - customer id: {0} at {1} (UTC {2})",
                                c.Id, DateTime.Now, DateTime.UtcNow));

                        email.ToName = c.GetFullName();
                        email.To = c.Email;
                        email.Subject = emailSubject;
                        email.Body = "The body of this email will hold other important statistics in the future";
                        email.CreatedOnUtc = DateTime.UtcNow;

                        _queuedEmailService.InsertQueuedEmail(email);
                        //SuccessNotification(_localizationService.GetResource("Admin.Customers.Customers.SendEmail.Queued"));
                    }
                    catch (Exception exc)
                    {
                        //_logger.Warning(string.Format("AwardInternetSaleTask Operations Manager email failed!  - customer id: {0} sale: {1} store: {2} at {3} (UTC {4}): Exception Message: {5}",
                        //    c.Id, s.AUSaleID, s.SaleStoreID, DateTime.Now, DateTime.UtcNow, exc.Message));

                        _logger.Warning(string.Format("ApplyMaximums Task Operations Manager email failed for id {0} subject {1} time {2}",
                             c.Id, emailSubject,  DateTime.Now));

                    }
                }
            }

        }
        public ActionResult Requeue(QueuedEmailModel queuedEmailModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMessageQueue))
                return AccessDeniedView();

            var queuedEmail = _queuedEmailService.GetQueuedEmailById(queuedEmailModel.Id);
            if (queuedEmail == null)
                //No email found with the specified id
                return RedirectToAction("List");

            var requeuedEmail = new QueuedEmail
            {
                PriorityId = queuedEmail.PriorityId,
                From = queuedEmail.From,
                FromName = queuedEmail.FromName,
                To = queuedEmail.To,
                ToName = queuedEmail.ToName,
                ReplyTo = queuedEmail.ReplyTo,
                ReplyToName = queuedEmail.ReplyToName,
                CC = queuedEmail.CC,
                Bcc = queuedEmail.Bcc,
                Subject = queuedEmail.Subject,
                Body = queuedEmail.Body,
                AttachmentFilePath = queuedEmail.AttachmentFilePath,
                AttachmentFileName = queuedEmail.AttachmentFileName,
                AttachedDownloadId = queuedEmail.AttachedDownloadId,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = queuedEmail.EmailAccountId
            };
            _queuedEmailService.InsertQueuedEmail(requeuedEmail);

            SuccessNotification(_localizationService.GetResource("Admin.System.QueuedEmails.Requeued"));
            return RedirectToAction("Edit", new { id = requeuedEmail.Id });
        }
Exemplo n.º 8
0
        /// <summary>
        /// Sends a campaign to specified emails
        /// </summary>
        /// <param name="campaign">Campaign</param>
        /// <param name="emailAccount">Email account</param>
        /// <param name="subscriptions">Subscriptions</param>
        /// <returns>Total emails sent</returns>
        public virtual int SendCampaign(Campaign campaign, EmailAccount emailAccount,
            IEnumerable<NewsLetterSubscription> subscriptions)
        {
            if (campaign == null)
                throw new ArgumentNullException("campaign");

            if (emailAccount == null)
                throw new ArgumentNullException("emailAccount");

            int totalEmailsSent = 0;

            foreach (var subscription in subscriptions)
            {
                var tokens = new List<Token>();
                _messageTokenProvider.AddStoreTokens(tokens);
                _messageTokenProvider.AddNewsLetterSubscriptionTokens(tokens, subscription);

                string subject = _tokenizer.Replace(campaign.Subject, tokens, false);
                string body = _tokenizer.Replace(campaign.Body, tokens, true);

                var email = new QueuedEmail()
                {
                    Priority = 3,
                    From = emailAccount.Email,
                    FromName = emailAccount.DisplayName,
                    To = subscription.Email,
                    Subject = subject,
                    Body = body,
                    CreatedOnUtc = DateTime.UtcNow,
                    EmailAccountId = emailAccount.Id
                };
                _queuedEmailService.InsertQueuedEmail(email);
                totalEmailsSent++;
            }
            return totalEmailsSent;
        }
Exemplo n.º 9
0
        public ActionResult SendEmail(CustomerModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
                return AccessDeniedView();

            var customer = _customerService.GetCustomerById(model.Id);
            if (customer == null)
                //No customer found with the specified id
                return RedirectToAction("List");

            try
            {
                if (String.IsNullOrWhiteSpace(customer.Email))
                    throw new NopException("Customer email is empty");
                if (!CommonHelper.IsValidEmail(customer.Email))
                    throw new NopException("Customer email is not valid");
                if (String.IsNullOrWhiteSpace(model.SendEmail.Subject))
                    throw new NopException("Email subject is empty");
                if (String.IsNullOrWhiteSpace(model.SendEmail.Body))
                    throw new NopException("Email body is empty");

                var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
                if (emailAccount == null)
                    emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
                if (emailAccount == null)
                    throw new NopException("Email account can't be loaded");

                var email = new QueuedEmail
                {
                    Priority = 5,
                    EmailAccountId = emailAccount.Id,
                    FromName = emailAccount.DisplayName,
                    From = emailAccount.Email,
                    ToName = customer.GetFullName(),
                    To = customer.Email,
                    Subject = model.SendEmail.Subject,
                    Body = model.SendEmail.Body,
                    CreatedOnUtc = DateTime.UtcNow,
                };
                _queuedEmailService.InsertQueuedEmail(email);
                SuccessNotification(_localizationService.GetResource("Admin.Customers.Customers.SendEmail.Queued"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc.Message);
            }

            return RedirectToAction("Edit", new { id = customer.Id });
        }
        protected virtual int SendNotification(MessageTemplate messageTemplate, 
            EmailAccount emailAccount, int languageId, IEnumerable<Token> tokens,
            string toEmailAddress, string toName,
            string attachmentFilePath = null, string attachmentFileName = null,
            string replyToEmailAddress = null, string replyToName = null)
        {
            //retrieve localized message template data
            var bcc = messageTemplate.GetLocalized(mt => mt.BccEmailAddresses, languageId);
            var subject = messageTemplate.GetLocalized(mt => mt.Subject, languageId);
            var body = messageTemplate.GetLocalized(mt => mt.Body, languageId);

            //Replace subject and body tokens 
            var subjectReplaced = _tokenizer.Replace(subject, tokens, false);
            var bodyReplaced = _tokenizer.Replace(body, tokens, true);
            
            var email = new QueuedEmail
            {
                Priority = QueuedEmailPriority.High,
                From = emailAccount.Email,
                FromName = emailAccount.DisplayName,
                To = toEmailAddress,
                ToName = toName,
                ReplyTo = replyToEmailAddress,
                ReplyToName = replyToName,
                CC = string.Empty,
                Bcc = bcc,
                Subject = subjectReplaced,
                Body = bodyReplaced,
                AttachmentFilePath = attachmentFilePath,
                AttachmentFileName = attachmentFileName,
                AttachedDownloadId = messageTemplate.AttachedDownloadId,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = emailAccount.Id
            };

            _queuedEmailService.InsertQueuedEmail(email);
            return email.Id;
        }
Exemplo n.º 11
0
 public static QueuedEmail ToEntity(this QueuedEmailModel model, QueuedEmail destination)
 {
     return Mapper.Map(model, destination);
 }
        protected virtual int SendNotification(MessageTemplate messageTemplate, 
            EmailAccount emailAccount, int languageId, IEnumerable<Token> tokens,
            string toEmailAddress, string toName,
            string attachmentFilePath = null, string attachmentFileName = null,
            string replyToEmailAddress = null, string replyToName = null)
        {
            if (messageTemplate == null)
                throw new ArgumentNullException("messageTemplate");
            if (emailAccount == null)
                throw new ArgumentNullException("emailAccount");

            //retrieve localized message template data
            var bcc = messageTemplate.GetLocalized(mt => mt.BccEmailAddresses, languageId);
            var subject = messageTemplate.GetLocalized(mt => mt.Subject, languageId);
            var body = messageTemplate.GetLocalized(mt => mt.Body, languageId);

            //Replace subject and body tokens 
            var subjectReplaced = _tokenizer.Replace(subject, tokens, false);
            var bodyReplaced = _tokenizer.Replace(body, tokens, true);

            //limit name length
            toName = CommonHelper.EnsureMaximumLength(toName, 300);
            
            var email = new QueuedEmail
            {
                Priority = QueuedEmailPriority.High,
                From = emailAccount.Email,
                FromName = emailAccount.DisplayName,
                To = toEmailAddress,
                ToName = toName,
                ReplyTo = replyToEmailAddress,
                ReplyToName = replyToName,
                CC = string.Empty,
                Bcc = bcc,
                Subject = subjectReplaced,
                Body = bodyReplaced,
                AttachmentFilePath = attachmentFilePath,
                AttachmentFileName = attachmentFileName,
                AttachedDownloadId = messageTemplate.AttachedDownloadId,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = emailAccount.Id,
                DontSendBeforeDateUtc = !messageTemplate.DelayBeforeSend.HasValue ? null
                    : (DateTime?)(DateTime.UtcNow + TimeSpan.FromHours(messageTemplate.DelayPeriod.ToHours(messageTemplate.DelayBeforeSend.Value)))
            };

            _queuedEmailService.InsertQueuedEmail(email);
            return email.Id;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Sends a campaign to specified emails
        /// </summary>
        /// <param name="campaign">Campaign</param>
        /// <param name="emailAccount">Email account</param>
        /// <param name="subscriptions">Subscriptions</param>
        /// <returns>Total emails sent</returns>
        public virtual int SendCampaign(Campaign campaign, EmailAccount emailAccount,
            IEnumerable<NewsLetterSubscription> subscriptions)
        {
            if (campaign == null)
                throw new ArgumentNullException("campaign");

            if (emailAccount == null)
                throw new ArgumentNullException("emailAccount");

            int totalEmailsSent = 0;

            foreach (var subscription in subscriptions)
            {
                var customer = _customerService.GetCustomerByEmail(subscription.Email);
                //ignore deleted or inactive customers when sending newsletter campaigns
                if (customer != null && (!customer.Active || customer.Deleted))
                    continue;

                var tokens = new List<Token>();
                _messageTokenProvider.AddStoreTokens(tokens, _storeContext.CurrentStore, emailAccount);
                _messageTokenProvider.AddNewsLetterSubscriptionTokens(tokens, subscription);
                if (customer != null)
                    _messageTokenProvider.AddCustomerTokens(tokens, customer);

                string subject = _tokenizer.Replace(campaign.Subject, tokens, false);
                string body = _tokenizer.Replace(campaign.Body, tokens, true);

                var email = new QueuedEmail
                {
                    Priority = QueuedEmailPriority.Low,
                    From = emailAccount.Email,
                    FromName = emailAccount.DisplayName,
                    To = subscription.Email,
                    Subject = subject,
                    Body = body,
                    CreatedOnUtc = DateTime.UtcNow,
                    EmailAccountId = emailAccount.Id
                };
                _queuedEmailService.InsertQueuedEmail(email);
                totalEmailsSent++;
            }
            return totalEmailsSent;
        }
Exemplo n.º 14
0
        public ActionResult Requeue(QueuedEmailModel queuedEmailModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMessageQueue))
                return AccessDeniedView();

            var queuedEmail = _queuedEmailService.GetQueuedEmailById(queuedEmailModel.Id);
            if (queuedEmail != null)
            {
                var requeuedEmail = new QueuedEmail()
                {
                    Priority = queuedEmail.Priority,
                    From = queuedEmail.From,
                    FromName = queuedEmail.FromName,
                    To = queuedEmail.To,
                    ToName = queuedEmail.ToName,
                    CC = queuedEmail.CC,
                    Bcc = queuedEmail.Bcc,
                    Subject = queuedEmail.Subject,
                    Body = queuedEmail.Body,
                    CreatedOnUtc = DateTime.UtcNow,
                    EmailAccountId = queuedEmail.EmailAccountId
                };
                _queuedEmailService.InsertQueuedEmail(requeuedEmail);

                SuccessNotification(_localizationService.GetResource("Admin.System.QueuedEmails.Requeued"));
                return RedirectToAction("Edit", requeuedEmail.Id);
            }
            else
                return RedirectToAction("List");
        }
        /// <summary>
        /// Executes a task
        /// </summary>
        public void Execute()
        {
            //60*24 = 1 day
            //var olderThanMinutes = 1440; //TODO move to settings
            //Do not delete more than 1000 records per time. This way the system is not slowed down
            //_customerService.DeleteGuestCustomers(null, DateTime.UtcNow.AddMinutes(-olderThanMinutes), true);

            //sales = _saleRepo.GetById(SaleId);




            //******************************************************************************************************************
            //* AWARD ANY INTERNET SALE THAT IS NOW PAST IS CLOSING TIME THAT IS NOT ALREADY CLOSED. NOTE THAT LIVE SALES WILL NOT BE
            //* BE AUTO-AWARDED - THEY WILL GRADUALLY CLOSE AS THE LIVE AUCTION IS RUN
            //******************************************************************************************************************
            DateTime currTime = DateTime.UtcNow;

            var query = _saleRepo.Table ;
            query = query.Where(c => c.SaleIsActive == false);                           //double check to make sure the sale is not already active
//            query = query.Where(c => c.SaleType == AUSaleTypeEnum.InternetAuction);     // Right now any future saletype will be activated
            query = query.Where(c => c.SaleStartDateTime <= currTime);                    //Make sure the Internet sale is over

            var futureSales = query.ToList();

            if (futureSales == null)  //no sales to award -get outta here
                return;

            //***************************************************************************************************************
            //* There is a sale to award - get the people with roles of Operations Manager so you can notify them of results
            //***************************************************************************************************************
            int omRoleId = _consignorService.GetIdForRole("OperationsManager");
            int[] customerRoleIds = new int[1];
            
            if (omRoleId != 0)
            {
                customerRoleIds[0] = omRoleId;
            }
            else
            {
                customerRoleIds[0] = 0;  //CustomerRole table begins with 1
                _logger.Warning(string.Format("ActivateSale Task could not find a Customer with Operations Manager Role to email results at {0} (UTC {1})",
                    DateTime.Now, DateTime.UtcNow));
            }

            //this will only find customers with the Operations Manager role
            var omCustomers = _customerService.GetAllCustomers(
                    customerRoleIds: customerRoleIds,
                    pageIndex: 0,
                    pageSize: 500);
           

            var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
            if (emailAccount == null)
                emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
            if (emailAccount == null)
                _logger.Warning(string.Format("ActivateSale Task could not find an email account to email sale award notifications at {0} (UTC {1})",
                    DateTime.Now, DateTime.UtcNow));

            //************************************************************************************************************
            //* GET THE EMAILACCOUNT TO USE
            //***********************************************************************************************************
           
            
             var email = new QueuedEmail
                {
                    Priority = QueuedEmailPriority.High,
                    EmailAccountId = emailAccount.Id,
                    FromName = emailAccount.DisplayName,
                    From = emailAccount.Email,
                    
                };
           
            foreach (var s in futureSales)
            {
                _consignorService.ActivateSale(s.AUSaleID, s.SaleStoreID);
                _logger.Information(string.Format("ActivateSaleTask activated sale {0} in store {1} at {2} (UTC {3})",
                    s.AUSaleNbr, s.SaleStoreID, DateTime.Now, DateTime.UtcNow));

                if (emailAccount != null)  //can only send emails if an smtp account is set up
                {
                    foreach (var c in omCustomers)  //send sale awarded email to all Operations Managers
                    {
                        try
                        {
                            if (String.IsNullOrWhiteSpace(c.Email))
                                _logger.Warning(string.Format("ActivateSaleTask Operations Manager does not have an email to send sale activation notification - customer id: {0} sale: {1} store: {2} at {3} (UTC {4})",
                                    c.Id, s.AUSaleID, s.SaleStoreID, DateTime.Now, DateTime.UtcNow));
                            if (!CommonHelper.IsValidEmail(c.Email))
                                _logger.Warning(string.Format("ActivateSaleTask Operations Manager does not have a valid email to send sale activation notification - customer id: {0} sale: {1} store: {2} at {3} (UTC {4})",
                                    c.Id, s.AUSaleID, s.SaleStoreID, DateTime.Now, DateTime.UtcNow));

                            email.ToName = c.GetFullName();
                            email.To = c.Email;
                            email.Subject = "Sale has been activated: " + s.AUSaleNbr + ":" + s.SaleTitle;
                            email.Body = "The body of this email will hold other important statistics in the future";
                            email.CreatedOnUtc = DateTime.UtcNow;

                            _queuedEmailService.InsertQueuedEmail(email);
                            //SuccessNotification(_localizationService.GetResource("Admin.Customers.Customers.SendEmail.Queued"));
                        }
                        catch (Exception exc)
                        {
                            _logger.Warning(string.Format("ActivateSaleTask Operations Manager email failed!  - customer id: {0} sale: {1} store: {2} at {3} (UTC {4}): Exception Message: {5}",
                                c.Id, s.AUSaleID, s.SaleStoreID, DateTime.Now, DateTime.UtcNow, exc.Message));

                        }
                    }
                }
            }
       }