private static void SendEmails(Control report, DateTime date)
        {
            var emailAddresses = LogControl.GetPoliticianSigninEmailAddresses();

            if (IsNullOrWhiteSpace(emailAddresses))
            {
                return;
            }

            var mailMessage = new MailMessage
            {
                IsBodyHtml = true,
                From       = new MailAddress("*****@*****.**", "VoteUSA servers"),
                Subject    = $"Politician Sign-in Summary for {date.ToShortDateString()}",
                Body       = report.RenderToString()
            };

            mailMessage.To.Add(emailAddresses);
            EmailUtility.GetConfiguredSmtpClient().Send(mailMessage);
        }
Ejemplo n.º 2
0
        private void UnsubscribeAddresses(int id, string email, string op)
        {
            if (id == 0 || IsNullOrWhiteSpace(email) || op != "unsubscribe" && op != "ballots")
            {
                Message.InnerText = "The requested email address was not found";
                return;
            }

            var handled = true;

            if (Addresses.GetEmailById(id).SafeString().IsEqIgnoreCase(email))
            {
                if (op == "ballots")
                {
                    Response.Redirect(UrlManager.GetSampleBallotEnrollmentPageUri(email).ToString());
                    Response.End();
                }
                EmailUtility.UpdateSubscription(email, op);
            }
            else
            {
                handled = false;
            }
            if (!handled)
            {
                return;
            }
            switch (op)
            {
            case "unsubscribe":
                Message.InnerText =
                    $"Email {email} has been unsubscribed from all future email.";
                break;

            case "ballots":
                Message.InnerText =
                    $"We will send future ballot choices to {email} as soon as they become available.";
                break;
            }
        }