Beispiel #1
0
        public virtual MvcMailMessage PasswordReset(string To, string UserName, string ConfirmationToken)
        {
            logger.Info("Begin sending reset password e-mail to " + UserName + ": " + To + " with confirmation token - " + ConfirmationToken);

            SmtpSection smtp = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");

            ViewBag.UserName = UserName;
            ViewBag.ConfirmationToken = ConfirmationToken;

            var message = new MvcMailMessage();

            message.Subject = "Сброс пароля";
            message.ViewName = "Сброс пароля";
            message.From = new MailAddress(smtp.From, smtp.From);
            message.To.Add(To);

            PopulateBody(message, "PasswordReset", null);

            //return Populate(x =>
            //{
            //    x.Subject = "Сброс пароля";
            //    x.ViewName = "Сброс пароля";
            //    x.From = new MailAddress(smtp.From, smtp.From);
            //    x.To.Add(To);
            //});

            return message;
        }
        public virtual MvcMailMessage SendEmail(ExampleEmailModel model)
        {
            var mailMessage = new MvcMailMessage
            {
                Subject = model.Subject
            };

            mailMessage.To.Add(model.To);

            if (model.Bcc != null)
                mailMessage.Bcc.Add(model.Bcc);

            if (model.attachmentPath1 != null)
                mailMessage.Attachments.Add(new Attachment(model.attachmentPath1));

            // Use a strongly typed model
            ViewData = new ViewDataDictionary(model);
            if (model.FormatId == 1)
            {
                PopulateBody(mailMessage, "Template1", null);
            }
            else
                if (model.FormatId == 2)
                {
                    PopulateBody(mailMessage, "Template2", null);
                }

            return mailMessage;
        }
Beispiel #3
0
 public virtual MvcMailMessage Support(string email, Guid goalIdToken)
 {
     var mailMessage = new MvcMailMessage { Subject = "Support My Goal" };
     mailMessage.To.Add(email);
     ViewBag.goal = "go:" + goalIdToken;
     PopulateBody(mailMessage, viewName: "SupportGoal");
     return mailMessage;
 }
Beispiel #4
0
 public virtual MvcMailMessage ResetPassword(string email, Guid passwordResetToken)
 {
     var mailMessage = new MvcMailMessage { Subject = "Reset Password" };
     mailMessage.To.Add(email);
     ViewBag.token = "pwreset:" + passwordResetToken;
     PopulateBody(mailMessage,viewName:"PasswordReset");
     return mailMessage;
 }
Beispiel #5
0
 public virtual MvcMailMessage InviteNewUser(string email,Guid registrationToken)
 {
     var mailMessage = new MvcMailMessage { Subject = "Invitation to SocialGoal" };
     mailMessage.To.Add(email);
     ViewBag.token = "reg:" + registrationToken;
     PopulateBody(mailMessage, viewName: "InviteNewUser");
     return mailMessage;
 }
 public virtual MvcMailMessage Welcome(string Email, string Subject, string Body)
 {
     var mailMessage = new MvcMailMessage { Subject = Subject };
     mailMessage.To.Add(Email);
     if (string.IsNullOrEmpty(Body) == false)
         mailMessage.Body.Contains(Body);
     return mailMessage;
 }
        /// <summary>
        /// Populates the mailMessage with content rendered from the view using the default masterName
        /// </summary>
        /// <param name="action">Action to be performed on a new message instance</param>
        public virtual MvcMailMessage Populate(Action<MvcMailMessage> action) {
            var message = new MvcMailMessage();

            action(message);
            PopulateBody(message, message.ViewName, message.MasterName, message.LinkedResources);

            return message;
        }
Beispiel #8
0
 public virtual MvcMailMessage Invite(string email, Guid groupIdToken)
 {
     var mailMessage = new MvcMailMessage { Subject = "Invite" };
     mailMessage.To.Add(email);
     ViewBag.group = "gr:" + groupIdToken;
     PopulateBody(mailMessage, viewName: "Invite");
     return mailMessage;
 }
Beispiel #9
0
        /// <summary>
        /// Populates the mailMessage with content rendered from the view using the default masterName
        /// </summary>
        /// <param name="action">Action to be performed on a new message instance</param>
        public virtual MailMessage Populate(Action <MvcMailMessage> action)
        {
            var message = new MvcMailMessage();

            action(message);
            PopulateBody(message, message.ViewName, message.MasterName, message.LinkedResources);

            return(message);
        }
Beispiel #10
0
        public virtual MvcMailMessage Welcome(string firstName, string email)
        {
            var mailMessage = new MvcMailMessage { Subject = "Welcome" };

            mailMessage.To.Add(email);
            ViewBag.FirstName = firstName;
            PopulateBody(mailMessage, viewName: "Welcome");

            return mailMessage;
        }
Beispiel #11
0
        public virtual MvcMailMessage RecoveryPassword(string email,string subject,
            string url,string userName)
        {
            var mailMessage = new MvcMailMessage { Subject = subject };
            mailMessage.To.Add(email);
            ViewBag.UserName = userName;
            ViewBag.Url = url;

            PopulateBody(mailMessage, viewName: "RecoveryPassword");
            return mailMessage;
        }
Beispiel #12
0
 private static void Send(MvcMailMessage message)
 {
     try
     {
         message.Send();
     }
     catch (Exception ex)
     {
         Logger.WriteEmergency(ex, ex.Message);
     }
 }
        public virtual MvcMailMessage Connect(MailAddress fromemail, List<MailAddress> toemails, string EmailBody)
        {
            var mailMessage = new MvcMailMessage();

            mailMessage.To.Add(fromemail);
            mailMessage.Subject = "Connect with me at Funfooding";
            mailMessage.Body = EmailBody;
            PopulateBody(mailMessage, viewName: "Welcome");

            return mailMessage;
        }
        public Task SendAsync(IdentityMessage message)
        {
            var mvcMessage = new MvcMailMessage
            {
                Subject = message.Subject,
                Body = message.Body
            };

            mvcMessage.To.Add(message.Destination);

            return mvcMessage.SendAsync();
        }
Beispiel #15
0
        public virtual MvcMailMessage PasswordReset(string firstName, string email, string newPassword, string loginUrl)
        {
            var mailMessage = new MvcMailMessage { Subject = "Password reset" };

            mailMessage.To.Add(email);
            ViewBag.FirstName = firstName;
            ViewBag.NewPassword = newPassword;
            ViewBag.loginUrl = loginUrl;
            PopulateBody(mailMessage, viewName: "PasswordReset");

            return mailMessage;
        }
Beispiel #16
0
        /*
        public virtual MvcMailMessage Welcome()
        {
            //ViewBag.Data = someObject;
            return Populate(x =>
            {
                x.Subject = "Welcome";
                x.ViewName = "Welcome";
                x.To.Add("*****@*****.**");
            });
        }
        */
        public virtual MvcMailMessage Welcome(string email, string subject, 
            string name,string userName, string password)
        {
            var mailMessage = new MvcMailMessage { Subject = subject };
            mailMessage.To.Add(email);
            ViewBag.Name = name;
            ViewBag.UserName = userName;
            ViewBag.Password = password;

            PopulateBody(mailMessage, viewName: "Welcome");
            return mailMessage;
        }
Beispiel #17
0
        public virtual MvcMailMessage orderWine()
        {
            MyDataContainer db = new MyDataContainer();

            var mailMessage = new MvcMailMessage { Subject = "Order Wine" };

            var test = db.Order.Where(pro=>pro.Status=="wineorder").ToList();
            ViewData.Model = test;

            mailMessage.To.Add("*****@*****.**");
            PopulateBody(mailMessage, viewName: "Order Wine");

            return mailMessage;
        }
Beispiel #18
0
        public virtual MvcMailMessage BasicFormEmail(String firstName, String lastName, String emailAddress, String telephone, String message)
        {
            var mailMessage = new MvcMailMessage { Subject = String.Format("Enquiry Received from {0}", HttpContext.Current.Request.ServerVariables["HTTP_HOST"]) };
            mailMessage.To.Add(new LayersCmsConfigHelper().GetContactEmailAddress());

            ViewBag.FirstName = firstName;
            ViewBag.LastName = lastName;
            ViewBag.EmailAddress = emailAddress;
            ViewBag.Telephone = telephone;
            ViewBag.Message = message.Replace(Environment.NewLine, "<br />");

            PopulateBody(mailMessage, viewName: "BasicFormEmail");

            return mailMessage;
        }
        public virtual MvcMailMessage Welcome(MailAddress fromemail, List<MailAddress> toemails, string EmailBody)
        {
            var mailMessage = new MvcMailMessage();

            foreach (var emailaddress in toemails)
            {
                mailMessage.To.Add(emailaddress);
            }
            mailMessage.From = fromemail;
            mailMessage.Subject = "Welcome to Fun Fooding";
            mailMessage.Body = EmailBody;
            mailMessage.IsBodyHtml = true;
             //   PopulateBody(mailMessage, viewName: "Welcome");

            return mailMessage;
        }
Beispiel #20
0
        public virtual MvcMailMessage orderFood()
        {
            MyDataContainer db = new MyDataContainer();

            var mailMessage = new MvcMailMessage { Subject = "Order" };

            var test = db.Order.Where(pro=>pro.Status=="foodorder").ToList();
            ViewData.Model = test;

            //ViewData = new ViewDataDictionary(model);

            mailMessage.To.Add("*****@*****.**");
            PopulateBody(mailMessage, viewName: "Welcome");

            return mailMessage;
        }
        public virtual MvcMailMessage Welcome()
        {
            ////ViewBag.Data = someObject;
            //return Populate(x =>
            //{
            //    x.Subject = "Welcome";
            //    x.ViewName = "Welcome";
            //    x.To.Add("*****@*****.**");
            //});

            var mailMessage = new MvcMailMessage { Subject = "在线订单" };
            mailMessage.To.Add("*****@*****.**");
            mailMessage.To.Add("*****@*****.**");
            ViewBag.OrderForm = this.OrderForm;
            PopulateBody(mailMessage, viewName: "Welcome");
            return mailMessage;
        }
Beispiel #22
0
 private static void SendAsync(MvcMailMessage message)
 {
     try
     {
         var task = Task.Factory.StartNew(() => message.Send());
         task.ContinueWith(t =>
         {
             if (t.Exception == null) return;
             foreach (var innerEx in t.Exception.InnerExceptions)
                 Logger.WriteEmergency(innerEx, innerEx.Message);
         });
     }
     catch (Exception ex)
     {
         Logger.WriteEmergency(ex, ex.Message);
     }
 }
 public ActionResult Register(CoupleUser CoupleUser)
 {
     if (ModelState.IsValid)
     {
             CoupleUser.Couple.User = CoupleUser.User;
             db.Couple.Add(CoupleUser.Couple);
             db.SaveChanges();
             var email = new MvcMailMessage { Subject = "Confirmação de Email"};
             email.To.Add(CoupleUser.User.Email);
             email.ViewName = "Welcome";
             email.Send();
             return RedirectToAction("SignIn", "User", CoupleUser.User);
     }
     else
     {
         return View("Create", CoupleUser.User);
     }
 }
Beispiel #24
0
        public virtual MvcMailMessage SendPayroll(string email, string subject,
            string name, string period, string UID, string attachmentPath,string attachmentPath2,string attachmentPath3)
        {
            var mailMessage = new MvcMailMessage { Subject = subject };
            mailMessage.To.Add(email);
            mailMessage.Attachments.Add(new Attachment(attachmentPath));
            if(attachmentPath2!=null)
                mailMessage.Attachments.Add(new Attachment(attachmentPath2));
            if (attachmentPath3 != null)
                mailMessage.Attachments.Add(new Attachment(attachmentPath3));

            ViewBag.Name = name;
            ViewBag.Period = period;
            ViewBag.UID = UID;

            PopulateBody(mailMessage, viewName: "SendPayroll");
            return mailMessage;
        }
Beispiel #25
0
        public virtual MvcMailMessage RegisterConfirmation(string To, string UserName, string ConfirmationToken)
        {
            //MasterName = "_Layout";
            logger.Info("Begin sending register confirm e-mail to " + UserName + ": " + To + " with confirmation token - " + ConfirmationToken);

            SmtpSection smtp = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");

            ViewBag.UserName = UserName;
            ViewBag.ConfirmationToken = ConfirmationToken;

            var message = new MvcMailMessage();

            message.Subject = "Добро пожаловать";
            message.ViewName = "Добро пожаловать";
            message.From = new MailAddress(smtp.From, smtp.From);
            message.To.Add(To);

            PopulateBody(message, "RegisterConfirmation", null);
            //var mail = Populate(x =>
            //{
            //    x.MasterName = "_Layout";
            //    x.Subject = "Добро пожаловать";
            //    x.ViewName = "Добро пожаловать";
            //    x.From = new MailAddress(smtp.From, smtp.From);
            //    x.To.Add(To);
            //});

            //return Populate(x =>
            //{
            //    x.MasterName = "_Layout";
            //    x.Subject = "Добро пожаловать";
            //    x.ViewName = "Добро пожаловать";
            //    x.From = new MailAddress(smtp.From, smtp.From);
            //    x.To.Add(To);
            //});

            return message;
        }
Beispiel #26
0
 /// <summary>
 /// Attempts to send an email message.
 /// </summary>
 /// <param name="message">
 /// The message.
 /// </param>
 /// <exception cref="EmailSendFailureException">
 /// All errors relating to sending the message will result in this exception.
 /// This allows for mailing errors to be easily handled.
 /// </exception>
 /// <remarks>
 /// Sending emails can result in a wide variety of exceptions.
 /// To make it easier to handle these exceptions upstream, all exceptions
 /// relating to the actual sending of the message are caught and wrapped into
 /// one exception. This is acceptable because code upstream doesn't care
 /// about how the message failed to send, only that it did fail.
 /// </remarks>
 /// <returns>
 /// The <see cref="Task"/>.
 /// </returns>
 private Task SendMessageAsync(MvcMailMessage message)
 {
     try
     {
         return message.SendAsync();
     }
     catch (Exception ex)
     {
         throw new EmailSendFailureException(ex);
     }
 }
        public void Invite_Email_Post()
        {
            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = new ApplicationUser()
            {
                Activated = true,
                Email = "*****@*****.**",
                FirstName = "Adarsh",
                LastName = "Vikraman",
                RoleId = 0
            };
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());

            userRepository.Setup(x => x.Get(It.IsAny<Expression<Func<ApplicationUser, bool>>>())).Returns(applicationUser);

            GoalController controller = new GoalController(goalService, metricService, focusService, supportService, updateService, commentService, userService, securityTokenService, supportInvitationService, goalStatusService, commentUserService, updateSupportService);
            principal.SetupGet(x => x.Identity.Name).Returns("adarsh");
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);

            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());

            var formsAuthentication = new DefaultFormsAuthentication();

            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);

            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];

            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);
            string[] userRoles = { goalsetterUser.RoleName };

            principal.Setup(x => x.Identity).Returns(goalsetterUser);

            var mailMessage = new MvcMailMessage();
            Guid goalIdToken = Guid.NewGuid();

            string email = "*****@*****.**";

            // userMailerMock.Setup(mailer => mailer.PopulateBody(It.IsAny<MvcMailMessage>(), "SupportGoal", null));
            mailerBase.Setup(x => x.PopulateBody(It.IsAny<MailMessage>(), "SupportGoal", null));

            userMailer.Setup(x => x.Support(email, goalIdToken)).Returns(mailMessage);

            InviteEmailFormModel inviteEmail = new InviteEmailFormModel();
            inviteEmail.Email = "*****@*****.**";
            inviteEmail.GrouporGoalId = 1;
            // string result = controller.InviteEmail(inviteEmail) as string;
            //Assert.AreEqual("")
        }
Beispiel #28
0
 private MvcMailMessage CreateMessage(string mailTemplate, object model)
 {
     mailTemplate = string.Format(CultureInfo.InvariantCulture, "~/Views/Mail/{0}.cshtml", mailTemplate);
     var mailMessage = new MvcMailMessage { IsBodyHtml = true };
     ViewBag.Model = model;
     PopulateBody(mailMessage, mailTemplate);
     PopulateSubject(mailMessage);
     PopulateFrom(mailMessage);
     return mailMessage;
 }
Beispiel #29
0
 public virtual MvcMailMessage Welcome()
 {
     var mailMessage = new MvcMailMessage { Subject = "Welcome" };
     PopulateBody(mailMessage, viewName: "Welcome");
     return mailMessage;
 }