Exemple #1
0
        public void SendStatementEmails(DateTime statementDate)
        {
            var housekeepers = _unitOfWork.Query <Housekeeper>();

            foreach (var housekeeper in housekeepers)
            {
                if (string.IsNullOrWhiteSpace(housekeeper.Email))
                {
                    continue;
                }

                var statementFilename
                    = _statementGenerator.SaveStatement(housekeeper.Old, housekeeper.FullName, statementDate);

                if (string.IsNullOrWhiteSpace(statementFilename))
                {
                    continue;
                }

                var emailAddress = housekeeper.Email;
                var emailBody    = housekeeper.StatementEmailBody;

                try
                {
                    _emailHandler.EmailFile(emailAddress, emailBody, statementFilename,
                                            string.Format("Sandpiper Statement {0:yyyy-MM} {1}", statementDate, housekeeper.FullName));
                }
                catch (Exception e)
                {
                    _messageBox.Show(e.Message, string.Format("Email failure: {0}", emailAddress),
                                     MessageBoxButtons.OK);
                }
            }
        }