Beispiel #1
0
        public void SendEmailAlert( UserAlert userAlert, IEnumerable<Post> postList )
        {
            string emailSubject = "Email Alerter";

            postList.ToList().ForEach( x => x.TimeSincePublished = x.PublishDateTime.ToFriendlyJumblistAlternateShortDateTimeString() );

            IDictionary tokens = new Hashtable();
            tokens.Add( "userAlert", userAlert );
            tokens.Add( "user", userAlert.User );
            tokens.Add( "postList", postList );
            tokens.Add( "homeurl", homeUrl );

            string emailBody = GenerateEmailText( tokens, "EmailAlert.vm" );

            SendMail( userAlert.User.Email, emailSubject, emailBody, true );
        }
Beispiel #2
0
        public ActionResult EmailTest()
        {
            string recipientEmail  = "*****@*****.**";
            //string recipientEmail = "*****@*****.**";
            User user = new User();
            user.UserId = 35;
            user.Name = "Stuart";
            user.Email = recipientEmail;
            user.Postcode = "TN31 6HG";

            Post post = postService.SelectRecord( 5001 );

            UserAlert userAlert = new UserAlert();
            userAlert.Name = "My great alert";
            userAlert.User = user;

            IQueryable<Post> postList = postService.SelectRecordList( Post.WhereDisplayEquals( true ) ).OrderByDescending( t => t.PublishDateTime ).Take( 5 );

            //mailService.SendTestEmail( post, user );
            //mailService.SendTestEmail( user );
            //mailService.SendRegistrationVerificationEmail( user );
            mailService.SendPostEmail( post, user );
            //mailService.SendForgottenPasswordEmail( user );
            //mailService.SendPasswordResetEmail( user, "newpassword" );
            //mailService.SendEmailAlert( userAlert, postList );

            var model = DefaultView.CreateModel();
            model.PageTitle = "2 Test Emails Sent";
            model.Message = new Message() { Text = "The recipient email address was " + recipientEmail + " and the BCC was " + ConfigurationManager.AppSettings["AdminEmail"], StyleClass = "message" };
            return View( model );
        }