public void EmailFinanceInformation(MailAddress fromaddress, Person p, List <MailAddress> list, string subject, string body) { var emailqueue = new EmailQueue { Queued = Util.Now, FromAddr = fromaddress.Address, FromName = fromaddress.DisplayName, Subject = subject, Body = body, QueuedBy = Util.UserPeopleId, Transactional = true, FinanceOnly = true }; EmailQueues.InsertOnSubmit(emailqueue); string addmailstr = null; if (list != null) { addmailstr = list.EmailAddressListToString(); } emailqueue.EmailQueueTos.Add(new EmailQueueTo { PeopleId = p.PeopleId, OrgId = Util2.CurrentOrgId, AddEmail = addmailstr, Guid = Guid.NewGuid(), }); SubmitChanges(); SendPersonEmail(emailqueue.Id, p.PeopleId); }
public EmailQueue CreateQueueForOrg(MailAddress from, string subject, string body, DateTime?schedule, int orgid, bool publicViewable, string cclist = null) { var emailqueue = new EmailQueue { Queued = Util.Now, FromAddr = from.Address, FromName = from.DisplayName, Subject = subject, Body = body, SendWhen = schedule, QueuedBy = Util.UserPeopleId, Transactional = false, PublicX = publicViewable, SendFromOrgId = orgid, CClist = cclist }; EmailQueues.InsertOnSubmit(emailqueue); SubmitChanges(); if (body.Contains("http://publiclink", ignoreCase: true)) { var link = ServerLink("/EmailView/" + emailqueue.Id); var re = new Regex("http://publiclink", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase); emailqueue.Body = re.Replace(body, link); } SubmitChanges(); return(emailqueue); }
public void Email(MailAddress From, Person p, List <MailAddress> addmail, string subject, string body, bool redacted) { var emailqueue = new EmailQueue { Queued = DateTime.Now, FromAddr = From.Address, FromName = From.DisplayName, Subject = subject, Body = body, QueuedBy = Util.UserPeopleId, Redacted = redacted, Transactional = true }; EmailQueues.InsertOnSubmit(emailqueue); string addmailstr = null; if (addmail != null) { addmailstr = addmail.EmailAddressListToString(); } emailqueue.EmailQueueTos.Add(new EmailQueueTo { PeopleId = p.PeopleId, OrgId = CurrentOrgId, AddEmail = addmailstr, Guid = Guid.NewGuid(), }); SubmitChanges(); SendPersonEmail(emailqueue.Id, p.PeopleId); }
public EmailQueue CreateQueue(int?queuedBy, MailAddress from, string subject, string body, DateTime?schedule, int tagId, bool publicViewable) { var tag = TagById(tagId); if (tag == null) { return(null); } var emailqueue = new EmailQueue { Queued = DateTime.Now, FromAddr = from.Address, FromName = from.DisplayName, Subject = subject, Body = body, SendWhen = schedule, QueuedBy = queuedBy, Transactional = false, PublicX = publicViewable, }; EmailQueues.InsertOnSubmit(emailqueue); SubmitChanges(); if (body.Contains("http://publiclink", ignoreCase: true)) { var link = Util.URLCombine(CmsHost, "/Manage/Emails/View/" + emailqueue.Id); var re = new Regex("http://publiclink", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase); emailqueue.Body = re.Replace(body, link); } var q = tag.People(this); var q2 = from p in q.Distinct() where p.EmailAddress != null where p.EmailAddress != "" where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false) where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr) orderby p.PeopleId select p.PeopleId; var i = 0; foreach (var pid in q2) { i++; emailqueue.EmailQueueTos.Add(new EmailQueueTo { PeopleId = pid, OrgId = CurrentOrgId, Guid = Guid.NewGuid() }); } SubmitChanges(); return(emailqueue); }
public EmailQueue CreateQueueForSupporters(int?queuedBy, MailAddress from, string subject, string body, DateTime?schedule, List <GoerSupporter> list, bool publicViewable) { var emailqueue = new EmailQueue { Queued = Util.Now, FromAddr = from.Address, FromName = from.DisplayName, Subject = subject, Body = body, SendWhen = schedule, QueuedBy = queuedBy, Transactional = false, PublicX = publicViewable, }; EmailQueues.InsertOnSubmit(emailqueue); SubmitChanges(); var q2 = from g in list where g.SupporterId != null where g.Supporter.EmailAddress != null where g.Supporter.EmailAddress != "" where (g.Supporter.SendEmailAddress1 ?? true) || (g.Supporter.SendEmailAddress2 ?? false) where g.Supporter.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr) orderby g.SupporterId select g; foreach (var g in q2) { emailqueue.EmailQueueTos.Add(new EmailQueueTo { PeopleId = g.SupporterId ?? 0, OrgId = Util2.CurrentOrgId, Guid = Guid.NewGuid(), GoerSupportId = g.Id, }); } SubmitChanges(); return(emailqueue); }
public EmailQueue CreateQueue(int?queuedBy, MailAddress from, string subject, string body, DateTime?schedule, int tagId, bool publicViewable, int?goerSupporterId = null, bool?ccParents = null, string cclist = null) { var tag = TagById(tagId); if (tag == null) { return(null); } var emailqueue = new EmailQueue { Queued = Util.Now, FromAddr = from.Address, FromName = from.DisplayName, Subject = subject, Body = body, SendWhen = schedule, QueuedBy = queuedBy, Transactional = false, PublicX = publicViewable, CCParents = ccParents, CClist = cclist, Testing = Util.IsInRoleEmailTest, ReadyToSend = false, // wait until all individual emailqueueto records are created. }; EmailQueues.InsertOnSubmit(emailqueue); SubmitChanges(); if (body.Contains("http://publiclink", ignoreCase: true)) { var link = ServerLink("/EmailView/" + emailqueue.Id); var re = new Regex("http://publiclink", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase); emailqueue.Body = re.Replace(body, link); } var q = tag.People(this); IQueryable <int> q2 = null; if (emailqueue.CCParents == true) { q2 = from p in q.Distinct() where (p.EmailAddress ?? "") != "" || (p.Family.HeadOfHousehold.EmailAddress ?? "") != "" || (p.Family.HeadOfHouseholdSpouse.EmailAddress ?? "") != "" where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false) || (p.Family.HeadOfHousehold.SendEmailAddress1 ?? false) || (p.Family.HeadOfHousehold.SendEmailAddress2 ?? false) || (p.Family.HeadOfHouseholdSpouse.SendEmailAddress1 ?? false) || (p.Family.HeadOfHouseholdSpouse.SendEmailAddress2 ?? false) where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr) orderby p.PeopleId select p.PeopleId; } else { q2 = from p in q.Distinct() where p.EmailAddress != null where p.EmailAddress != "" where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false) where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr) orderby p.PeopleId select p.PeopleId; } foreach (var pid in q2) { emailqueue.EmailQueueTos.Add(new EmailQueueTo { PeopleId = pid, OrgId = Util2.CurrentOrgId, Guid = Guid.NewGuid(), GoerSupportId = goerSupporterId, }); } emailqueue.ReadyToSend = true; SubmitChanges(); return(emailqueue); }