Exemple #1
0
        public string ParseEmailTemplate(EmailMessageVM emailMessageVM)
        {
            Engine.Razor.Compile(ConvertViewToString(EmailLayoutView), "EmailMailerLayout");

            var myParsedTemplate = Engine.Razor.RunCompile(ConvertViewToString(SendEmailView), "SendEmailView", null, emailMessageVM);

            return(myParsedTemplate);
        }
        public IHttpActionResult Send(EmailMessageVM emailVM)
        {
            emailVM.FromEmail = "*****@*****.**";
            var emailService = new EmailService.EmailService();

            emailService.Email(emailVM);

            return(Ok());
        }
Exemple #3
0
        public MvcMailMessage Email(EmailMessageVM model)
        {
            model.FromEmail = "*****@*****.**";
            model.Subject   = "This is from our site";

            var emailService = new EmailService();

            emailService.SendEmail(model);

            return(null);
        }
Exemple #4
0
        private async Task configSendEmailAsync(IdentityMessage message)
        {
            //init mail model
            var model = new EmailMessageVM()
            {
                ToAddress = message.Destination,
                Subject   = message.Subject,
                Message   = message.Body
            };

            // send email
            MailClient.SendEmail(model);
        }
        public void SendEmail(EmailMessageVM emailMessage)
        {
            ViewData.Model = emailMessage;

            var mvcMailMessage = Populate(x =>
            {
                x.From       = new MailAddress(emailMessage.FromEmail);
                x.Subject    = emailMessage.Subject;
                x.ViewName   = "Email";
                x.MasterName = "_EmailLayout";
                x.To.Add(emailMessage.ToEmail);
            });

            mvcMailMessage.Send();
        }
Exemple #6
0
        public void Email(EmailMessageVM emailVM)
        {
            var razorEngineService = new RazorEngineService();

            var msg = new MailMessage(emailVM.FromEmail, emailVM.ToEmail)
            {
                Subject    = emailVM.Subject,
                Body       = razorEngineService.ParseEmailTemplate(emailVM),
                IsBodyHtml = true
            };

            using (var smtpClient = new SmtpClient())
            {
                smtpClient.Send(msg);
            }
        }
Exemple #7
0
        private void NotifyNewVoter(VoteUserDTO voter)
        {
            // Send an email with this link
            var mailModel = new EmailMessageVM();

            mailModel.ToAddress = voter.Email;
            mailModel.Subject   = "Account Created on LAGSOBA '94";

            var callbackUrl = GetBaseUrl();

            string message = "Hello," +
                             "<br>An account has been created for you on the LAGSOBA '94 voting platform." +
                             "<br> Use this as your password to log in: " + voter.VoterId +
                             "<br> <html><body><a href='" + callbackUrl + "' style=\"padding: 8px 12px; border: 1px solid #5ed863;border-radius: 2px;font-family: Helvetica, Arial, sans-serif;font-size: 14px; color: #ffffff;background-color:#5ed863;text-decoration: none;font-weight:bold;display: inline-block;\">Log in now</a></body></html>" +
                             "<br><br><br>" +
                             "<html><body><p><em>If you you got this email as an error, kindly ignore.</em></p></body></html>";

            mailModel.Message = message;

            // send email
            MailClient.SendEmail(mailModel);
        }
Exemple #8
0
 public static bool SendEmail(EmailMessageVM model)
 {
     return(SendMessage(ConfigurationManager.AppSettings["adminEmail"], model.ToAddress, model.Subject, model.Message));
 }
        public ActionResult SendMeACopy()
        {
            // get userId
            var voterId = User.VoterId;

            // get all votes for user
            var userVotes = db.Votes.Where(x => x.VoterId == voterId).ToList();

            // init voteResult
            List <VoteResultVM> voteResults = new List <VoteResultVM>();

            foreach (var vote in userVotes)
            {
                var result = new VoteResultVM
                {
                    PositionName = db.Position.Where(x => x.Id == vote.PositionId).Select(x => x.Name).FirstOrDefault()
                };

                if (vote.CandidateId == null)
                {
                    result.CandidateName = "NO VOTE";
                }
                else
                {
                    result.CandidateName = db.VoteUsers.Where(x => x.VoterId == vote.CandidateId).Select(x => x.FirstName + " " + x.LastName).FirstOrDefault();
                }

                //add result
                voteResults.Add(result);
            }

            // construct result mail message
            string resultMail = "";

            foreach (var result in voteResults)
            {
                string votedFor = "<tr>" +
                                  "<td style=\"padding: .75rem;vertical-align: top;border-top: 1px solid #dee2e6;\">" + result.PositionName +
                                  "</td>" +
                                  "<td style=\"padding: .75rem;vertical-align: top;border-top: 1px solid #dee2e6;\">" + result.CandidateName +
                                  "</td>" +
                                  "</tr>";

                resultMail += votedFor;
            }

            // Send an email with this link
            var mailModel = new EmailMessageVM();

            mailModel.ToAddress = User.Email;
            mailModel.Subject   = "Voting Result - LAGSOBA '94";

            // get username and date
            string   userName = db.VoteUsers.Where(x => x.Email == User.Email).Select(x => x.FirstName + " " + x.LastName).FirstOrDefault();
            DateTime?voteDate = db.VoteUsers.Where(x => x.Email == User.Email).Select(x => x.LastVoteDateUtc).FirstOrDefault();

            string date;

            if (voteDate != null)
            {
                DateTime updatedVoteDate = voteDate ?? DateTime.Now;

                var day       = updatedVoteDate.Day;
                var dayOfWeek = updatedVoteDate.DayOfWeek;
                var month     = updatedVoteDate.ToString("MMMM");
                var year      = updatedVoteDate.Year;

                date = day + " " + month + ", " + year;
            }
            else
            {
                date = "-";
            }

            string message = "<html><body>" +
                             "<div style=\"text-align:center;max-width:600px;\">" +

                             "<h3 style=\"background-color: #64608e;margin-bottom: 0px;padding: 10px 0px;color: #fff;\">" +
                             "My Voting Summary - LAGSOBA '94  " +
                             "</h3>" +

                             "<div style=\"border:2px solid #64608e\">" +
                             "<table style=\"width: 100%;margin-bottom: 1rem;\">" +

                             "<tr>" +
                             "<th style=\"padding: .75rem;vertical-align: top;border-top: 1px solid #dee2e6;\"> Position</th>" +
                             "<th style=\"padding: .75rem;vertical-align: top;border-top: 1px solid #dee2e6;\"> Candidate Voted For</th>" +
                             "</tr>" + resultMail +

                             "</table>" +

                             "<div style=\"margin-bottom: 20px;\">" +
                             "<h6>The Vote Summary Above was casted by:</h6>" +
                             "<p style=\"margin: 0px;\"><strong>Name: </strong> " + userName + "</p>" +
                             "<p><strong>Last Vote On: </strong> " + date + "</p>" +
                             "</div>" +


                             "<p style=\"color: #846d6dc7;\"><em>Thanks For Voting</em></p>" +
                             "</div>" +
                             "</div>" +
                             "</body></html>";

            mailModel.Message = message;

            // send email
            MailClient.SendEmail(mailModel);

            return(Json(new { Status = 1, Message = "Your vote summary has been forwarded to your email" }, JsonRequestBehavior.AllowGet));
        }