private void Email2(IQueryable <Person> q, int queuedBy, string fromAddr, string fromName, string subject,
                            string body)
        {
            //db.Log($"Email2 {subject}");
            var from = new MailAddress(fromAddr, fromName);

            q = from p in q
                where p.EmailAddress != null
                where p.EmailAddress != ""
                where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                select p;
            var tag = db.PopulateSpecialTag(q, DbUtil.TagTypeId_Emailer);

            Util.IsInRoleEmailTest = TestEmail;
            var queueremail = db.People.Where(pp => pp.PeopleId == queuedBy).Select(pp => pp.EmailAddress).Single();

            Util.UserEmail = queueremail;
            db.SetCurrentOrgId(CurrentOrgId);

            var emailqueue = db.CreateQueue(queuedBy, from, subject, body, null, tag.Id, false);

            emailqueue.Transactional = Transactional;
            db.SendPeopleEmail(emailqueue.Id);
            //db.Log($"Email2 (queued) {subject}");
        }
Exemple #2
0
        public void Email(string savedquery, int queuedBy, string fromaddr, string fromname, string subject, string body, bool transactional = false)
        {
            var from = new MailAddress(fromaddr, fromname);
            var qB   = Db.QueryBuilderClauses.FirstOrDefault(c => c.Description == savedquery && c.SavedBy == "public");

            if (qB == null)
            {
                return;
            }
            var q = Db.PeopleQuery(qB.QueryId);

            if (qB.ParentsOf)
            {
                q = Db.PersonQueryParents(q);
            }

            q = from p in q
                where p.EmailAddress != null
                where p.EmailAddress != ""
                where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                select p;
            var tag        = Db.PopulateSpecialTag(q, DbUtil.TagTypeId_Emailer);
            var emailqueue = Db.CreateQueue(queuedBy, from, subject, body, null, tag.Id, false);

            Db.SendPeopleEmail(emailqueue.Id);
        }
Exemple #3
0
        private void Email2(CMSDataContext db2, IQueryable <Person> q, int queuedBy, string fromAddr, string fromName, string subject,
                            string body)
        {
            var from = new MailAddress(fromAddr, fromName);

            q = from p in q
                where p.EmailAddress != null
                where p.EmailAddress != ""
                where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                select p;
            var tag = db2.PopulateSpecialTag(q, DbUtil.TagTypeId_Emailer);

            Util.IsInRoleEmailTest = TestEmail;
            var queueremail = db2.People.Where(pp => pp.PeopleId == queuedBy).Select(pp => pp.EmailAddress).SingleOrDefault();

            if (!queueremail.HasValue())
            {
                throw new Exception("QueuedBy PeopleId not found in model.Email");
            }
            Util.UserEmail = queueremail;
            db2.SetCurrentOrgId(CurrentOrgId);

            var emailqueue = db2.CreateQueue(queuedBy, from, subject, body, null, tag.Id, false);

            emailqueue.Transactional = Transactional;
            db2.SendPeopleEmail(emailqueue.Id);
        }
Exemple #4
0
        private void Email2(CMSDataContext db2, IQueryable<Person> q, int queuedBy, string fromAddr, string fromName, string subject,
            string body)
        {
            var from = new MailAddress(fromAddr, fromName);
            q = from p in q
                where p.EmailAddress != null
                where p.EmailAddress != ""
                where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                select p;
            var tag = db2.PopulateSpecialTag(q, DbUtil.TagTypeId_Emailer);

            Util.IsInRoleEmailTest = TestEmail;
            var queueremail = db2.People.Where(pp => pp.PeopleId == queuedBy).Select(pp => pp.EmailAddress).SingleOrDefault();
            if(!queueremail.HasValue())
                throw new Exception("QueuedBy PeopleId not found in model.Email");
            Util.UserEmail = queueremail;
            db2.SetCurrentOrgId(CurrentOrgId);

            var emailqueue = db2.CreateQueue(queuedBy, from, subject, body, null, tag.Id, false);
            emailqueue.Transactional = Transactional;
            db2.SendPeopleEmail(emailqueue.Id);
        }