Exemple #1
0
        public static List <UserObject> GetUsers()
        {
            var cache = HttpContext.Current.Cache;
            List <UserObject> users = (List <UserObject>)cache[usersKey];

            if (users == null)
            {
                users = UserObject.GetUsers();
                cache.Insert(usersKey, users, null, DateTime.Now.AddMinutes(10), Cache.NoSlidingExpiration);
            }
            return(users);
        }
Exemple #2
0
        private static bool SendReleaseOfficerEmail(string subject, string body, ref string errorMsg)
        {
            bool          allMailSent    = false;
            List <string> recipientNames = new List <string>();

            try
            {
                Email  email   = new Email();
                string addInfo = string.Empty;
                email.SendTo  = new List <string>();
                email.Subject = subject;

                foreach (var user in UserObject.GetUsers().Where(n => n.IsInAnyRole("ReleaseOfficial")) ?? new List <UserObject>())
                {
                    if (!string.IsNullOrWhiteSpace(user.Email))
                    {
                        email.SendTo.Add(user.Email);
                        recipientNames.Add(user.FullName);
                    }
                }

                if (email.SendTo.Count == 0)
                {
                    email.SendTo.Add(Config.OwnerEmail);
                    addInfo = "<em><p><strong>This message has been sent to you in lieu of the intended target.  Their email was not found in Employee Repo. Please review the email and determine appropriate course of action.</strong></p></em><hr />";
                }

                email.Body = addInfo + body.Replace("{RecipientsName}", string.Join(" : ", recipientNames));
                AddContactInfo(ref email);
                email.Send();

                allMailSent = true;
            }
            catch (Exception ex)
            {
                errorMsg = $"Exeption Caught on sending Email: {ex.Message}";
            }
            return(allMailSent);
        }