Beispiel #1
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);
        }