Esempio n. 1
0
        public void Send(string content)
        {
            _smtpClient = new SmtpClient(Address, Port);
            _smtpClient.Credentials = new NetworkCredential(Account, Password);
            _smtpClient.EnableSsl = false;
            MailMessage mailMessage = new MailMessage();
            mailMessage.BodyEncoding = Encoding.UTF8;
            mailMessage.From = new MailAddress(From, SenderName, Encoding.UTF8);
            mailMessage.To.Add(To);
            mailMessage.Body = content;
            mailMessage.Subject = Subject;
            _smtpClient.Send(mailMessage);


            dynamic email = new Email("Example");
            email.To = "*****@*****.**";
            email.Send();


            var viewsPath = Path.GetFullPath(@"..\..\Views");

            var engines = new ViewEngineCollection();
            engines.Add(new FileSystemRazorViewEngine(viewsPath));

            var service = new EmailService(engines);
            dynamic email = new Email("Test");

            // Will look for Test.cshtml or Test.vbhtml in Views directory.
            email.Message = "Hello, non-asp.net world!";
            service.Send(email);
           // RESTORE DATABASE is terminating abnormally.
        }
        public ActionResult Contact(ContactModel model)
        {
            // Build the contact email using a dynamic object for flexibility
            dynamic email = new Email("Contact");
            email.To = ConfigurationManager.AppSettings["email:ContactToAddress"];
            email.From = ConfigurationManager.AppSettings["email:ContactFromAddress"];
            email.FirstName = model.FirstName;
            email.LastName = model.LastName;
            email.BusinessType = model.BusinessType;
            email.AddressLine1 = model.AddressLine1;
            email.AddressLine2 = model.AddressLine2;
            email.City = model.City;
            email.State = model.State;
            email.ZipCode = model.ZipCode;
            email.Country = model.Country == "Other" ? model.CountryName : model.Country;
            email.Phone = model.Phone;
            email.Email = model.Email;
            email.Comments = model.Comments;
            email.Send();

            // Set the ShowThanksMessage flag to provide user feedback on the page.
            model.ShowThanksMessage = true;

            return View(model);
        }
Esempio n. 3
0
        public static void NotifyOnEscalation(ContractTask task, string contractOwnerEmail)
        {
            dynamic email = new Email("EscalationMail");
            email.to = contractOwnerEmail;
            email.from = applicationEmail;

            email.Send();
        }
 public void QueueEmail(EmailViewModel emailViewModel)
 {
     dynamic email = new Email("SignUp");
     email.To = emailViewModel.To;
     email.ActivationToken = emailViewModel.ActivationToken;
     email.BaseDomain = configuration.BaseDomain;
     email.Send();
 }
Esempio n. 5
0
        public static void NotifyTaskOwner(ContractTask task)
        {
            dynamic email = new Email("NotificationMail");
            email.to = task.User.Email;
            email.from = applicationEmail;

            email.Send();
        }
Esempio n. 6
0
        public static bool SendHKNews(HKNewsPaper paper)
        {
            dynamic email = new Email("~/MailTemplates/HKNews.cshtml");
            email.Model = paper;
            email.Send();

            return true;
        }
Esempio n. 7
0
 public static void WelcomeSendPassword(string username, string toaddress, string pass)
 {
     dynamic email = new Email("~/MailTemplates/Teszt.cshtml");
     email.To = toaddress;
     email.UserName = username;
     email.Password = pass;
     email.Send();
 }
        public ActionResult SendSimple()
        {
            dynamic email = new Email("Simple");
            email.Date = DateTime.UtcNow.ToString();
            email.Send();

            return RedirectToAction("Sent", "Home");
        }
Esempio n. 9
0
 // GET: Home
 public ActionResult Index()
 {
     dynamic email = new Email("Example");
     email.To = "[email protected], [email protected], [email protected]";
     email.FunnyLink = "http://blog.respag.net";
     email.Fecha = DateTime.Now.ToString(@"dddd, dd \de MMMM \de yyyy");
     email.Send();
     return View();
 }
        public ActionResult ForgotThePassword(LoginViewModel loginModel)
        {
            dynamic email = new Email("ForgotThePassword");
            email.To = "*****@*****.**";
            email.FunnyLink = "Hello Alex :)";
            email.Send();

            return View();
        }
 public ActionResult Contact(string name, string useremail, string title, string message)
 {
     dynamic email = new Email("Contact");
     email.From = useremail;
     email.Name = name;
     email.Title = title;
     email.Message = message;
     email.Send();
     return View();
 }
Esempio n. 12
0
        public void Send_creates_EmailService_and_calls_Send()
        {
            var emailService = new Mock<IEmailService>();
            Email.CreateEmailService = () => emailService.Object;
            var email = new Email("Test");

            email.Send();

            emailService.Verify(s => s.Send(email));
        }
 public JsonResult ResetUserPassword(string username, string emailAddress)
 {
     var confirmationToken = WebSecurity.GeneratePasswordResetToken(username);
     dynamic email = new Email("ChngPasswordEmail");
     email.To = emailAddress;
     email.UserName = username;
     email.ConfirmationToken = confirmationToken;
     email.Send();
     return Json(new { success = true });
 }
        public Task SendAsync(IdentityMessage message)
        {
            dynamic email = new Email("AuthEmail");
            email.To = message.Destination;
            email.Body = message.Body;
            email.Subject = message.Subject;

            email.Send();

            return Task.FromResult(0);
        }
Esempio n. 15
0
 public static void RegistrationConfirmationEmail(RegistrationConfirmationEmail input)
 {
     dynamic email = new Email("RegistrationConfirmation");
     email.To = input.To;
     email.From = input.From;
     email.Subject = input.Subject;
     email.Cc = input.Cc;
     email.Bcc = input.Bcc;
     email.ConfirmationLink = input.ConfirmationLink;
     email.FullName = input.FullName;
     email.Send();
 }
Esempio n. 16
0
        public static void SendReportMail(List<string> attachmentPaths, ContractUser user)
        {
            dynamic email = new Email("ReportMail");
            email.to = user.Email;
            email.from = applicationEmail;

            foreach(string path in attachmentPaths)
            {
                email.Attach(new Attachment(path));
            }
            email.Send();
        }
Esempio n. 17
0
 public ActionResult CancelBooking(CancelReservationModel model, string submitButton)
 {
     if (submitButton == "Avbryt") return View("Index");
     var booking = _reservationService.GetReservation(model.BookingId);
     _reservationService.DeleteReservation(booking);
     if (model.SendMail)
     {
         dynamic email = new Email("CancelBookingEmail");
         email.To = model.Email;
         email.Message = model.Message;
         email.Send();
     }
     return View("BookingCanceled");
 }
        protected void SendEmail(string templateKey, string email, string subject, string htmlMessage, string plainTextMessage)
        {
            if (Mailer == null)
            {
                throw new NullMailerException();
            }

            dynamic message = new Postal.Email(templateKey);

            message.To               = email;
            message.HtmlMessage      = htmlMessage;
            message.PlainTextMessage = plainTextMessage;

            message.Send();
        }
Esempio n. 19
0
        public async Task <ActionResult> EmailSender(EmailSenderViewModel model)
        {
            Postal.Email email = null;
            string       callbackUrl;

            switch (model.SelectedEmailTypeId)
            {
            case (int)EmailTypeEnum.Welcome:
                callbackUrl = "http://localhost:8081/Account/ConfirmEmail?userId=0000000000&code=0000000000";
                email       = await _postalEmailHelper.SendConfirmationEmailAsync(model.Email, "Miguel Soriano", "password", callbackUrl, false);

                break;

            case (int)EmailTypeEnum.ReSendConfirmation:
                callbackUrl = "http://localhost:8081/Account/ConfirmEmail?userId=0000000000&code=0000000000";
                email       = await _postalEmailHelper.ResendConfirmationEmailAsync(model.Email, callbackUrl, false);

                break;

            case (int)EmailTypeEnum.ResetPassword:
                callbackUrl = "http://localhost:8081/Account/ConfirmEmail?userId=0000000000&code=0000000000";
                email       = await _postalEmailHelper.SendResetPasswordEmailAsync(model.Email, "Miguel Soriano", callbackUrl, false);

                break;

            case (int)EmailTypeEnum.PetShare:
                callbackUrl = "http://localhost:8081/Account/ConfirmEmail?userId=0000000000&code=0000000000";
                email       = await _postalEmailHelper.SendShareEmailEmailAsync(model.Email, "Marti", callbackUrl, false);

                break;
            }

            switch (model.SelectedViewTypeId)
            {
            case (int)EmailViewerTypeEnum.Browser:
                return(new EmailViewResult(email));

            case (int)EmailViewerTypeEnum.Email:
                email.Send();
                break;
            }

            this.SetAlertMessageInTempData(Models.Shared.AlertMessageTypeEnum.Success, "El correo fue enviado.");
            return(RedirectToAction("EmailSender"));
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                String FirstName = collection["FirstName"];
                String LastName = collection["LastName"];
                String EmailAddress = collection["EmailAddress"];
                String Description = collection["Description"];
                Boolean IsEnabled = collection["IsEnabled"].Contains("true");
                Boolean IsAdmin = collection["IsAdmin"].Contains("true");

                User user = new User();
                user.FirstName = FirstName;
                user.LastName = LastName;
                user.EmailAddress = EmailAddress;
                user.Description = Description;
                user.IsEnabled = IsEnabled;
                user.IsAdmin = IsAdmin;

                if (ModelState.IsValid)
                {
                    User createdUser = manager.Create(user);

                    dynamic email = new Email("Welcome");
                    email.Subject = "Welcome to LOVIS EOS";
                    email.User = user;
                    email.Deployment = ConfigurationManager.AppSettings["Deployment"];
                    email.FromName = ConfigurationManager.AppSettings["EmailFromName"];
                    email.FromEmail = ConfigurationManager.AppSettings["EmailFromEmail"];
                    email.Domain = ConfigurationManager.AppSettings["Domain"];
                    email.WebAccessServer = ConfigurationManager.AppSettings["WebAccessServer"];
                    email.ADFSUpdatePassword = ConfigurationManager.AppSettings["ADFSUpdatePassword"];
                    email.Send();

                    ViewBag.SuccessMessage = "The user has been successfully created.";
                    return View("Edit", createdUser);
                }
                return View(user);
            }
            catch (Exception Error)
            {
                ViewBag.ErrorMessage = Error.Message;
                return View("Error");
            }
        }
Esempio n. 21
0
        public static void OnDispatcherSet(object source, EventArgs e)
        {
            MyDbContext db = new MyDbContext();

            Contract tempContract = (Contract)source;

            //The dispatcher has to be loaded here because the nav property is not set at this point yet
            ContractUser dispatcher = db.Users.Find(tempContract.DispatcherId);

            //Notify Dispatcher
            dynamic email = new Email("DispatcherMail");
            email.to = dispatcher.Email;

            email.from = applicationEmail;
            email.contractId = tempContract.Id;

            email.Send();
            System.Diagnostics.Debug.WriteLine("Email wurde abgeschickt");
        }
Esempio n. 22
0
        public ActionResult Send(string to, string subject, string message, HttpPostedFileBase file)
        {
            // This will look for a view in "~/Views/Emails/Example.cshtml".
            dynamic email = new Email("Example");
            // Assign any view data to pass to the view.
            // It's dynamic, so you can put whatever you want here.
            email.To = to;
            email.Subject = subject;
            email.Message = message;
            email.Date = DateTime.UtcNow;

            if (file != null)
            {
                email.Attach(new Attachment(file.InputStream, file.FileName));
            }

            // Send the email via a default Postal.EmailService object.
            // This will use the web.config smtp settings.
            email.Send();

            // In 'real code' you probably want to use the Postal.IEmailService interface
            // to allow for mocking out the sending of email in tests.
            //
            // The controller's constructor would look like this:
            //   public HomeController(IEmailService emailService) {
            //     this.emailService = emailService;
            //   }
            //
            // Then actions can send email using:
            //   emailService.Send(email);

            // Alternatively, you can just ask for the MailMessage to be created.
            // It contains the rendered email body and headers (To, From, etc).
            // You can then send this yourself using any method you like.
            // using (var mailMessage = emailService.CreateMailMessage(email))
            // {
            //     MyEmailGateway.Send(mailMessage);
            // }

            return RedirectToAction("Sent");
        }
        public static void SendCorespondingEmail(Email email)
        {
            // ReSharper disable once AssignNullToNotNullAttribute
            /*var viewpath = Path.GetFullPath(HostingEnvironment.MapPath(@"~/Views/Emails"));
            var engines = new ViewEngineCollection();
            engines.Add(new FileSystemRazorViewEngine(viewpath));
            var emailService = new Postal.EmailService(engines);*/

            #region Setting Credentials using smtp client class instead of in web.config

            /*var client = new SmtpClient();
            var credential = new NetworkCredential("*****@*****.**", "mangapi.");
            client.UseDefaultCredentials = false;
            client.Credentials = credential;
            client.Host = "smtp.gmail.com";
            client.Port = 587;
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network; 

            var emailService = new Postal.EmailService(ViewEngines.Engines, () => client);*/

            #endregion

            try
            {
                //sending email using web.config credentials
                email.Send();

                //sending email using above credentials
                //emailService.Send(email);
            }
            catch (Exception exception)
            {
                ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(new Exception(exception.Message)));
            }

        }
        public ActionResult Register(RegisterModel model,string practiceId)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    string confirmationToken = WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.EmailAddress }, true);

                    var roles = (SimpleRoleProvider)Roles.Provider;
                    var r = roles.GetRolesForUser(model.UserName);
                    int i = 0;
                    // If user has no roles
                    if (r.Length == 0)
                    {
                        roles.AddUsersToRoles(new[] { model.UserName }, new[] { "User" });
                    }
                    // User may have another role so checking if they have the admin role
                    while (i < r.Length)
                    {
                        if (r[i] != "User")
                        {
                            roles.AddUsersToRoles(new[] { model.UserName }, new[] { "User" });
                        }
                        i++;
                    }

                    WebSecurity.Login(model.UserName, model.Password);
                    var userId = WebSecurity.GetUserId(model.UserName);
                    model.UpdateUser(userId, new Guid(practiceId), model.EmailAddress);

                    dynamic email = new Email("RegEmail");
                    email.To = model.EmailAddress;
                    email.UserName = model.UserName;
                    email.ConfirmationToken = confirmationToken;
                    email.Send();
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public ActionResult UnBanUser(string userName)
 {
     System.Web.Security.Roles.AddUserToRole(userName, "User");
     if (System.Web.Security.Roles.GetRolesForUser(userName).Contains("Banned"))
        {
        System.Web.Security.Roles.RemoveUserFromRole(userName, "Banned");
        }
        dynamic email = new Email("EmailToUser");
        email.To = userName;
        email.UserName = data.retrieveUserByEmail(userName).FirstName;
        email.message = "You have been unbanned!";
        email.Send();
        string success = "Your email Has been delivered.";
        VMGeneralMessage message = new VMGeneralMessage("Email", "Email Sent", new string[] { success });
        return View("GeneralMessage", message);
 }
        public ActionResult SendEmailToUser(VMSendEmailToUser emails)
        {
            if (ModelState.IsValid)
            {

                if (data.retrieveUserByEmail(emails.to) != null)
                {
                    dynamic email = new Email("EmailToUser");
                    email.To = emails.to;
                    email.UserName = data.retrieveUserByEmail(emails.to).FirstName;
                    email.message = emails.message;
                    email.Send();
                    string success = "Your email Has been delivered.";
                    VMGeneralMessage message = new VMGeneralMessage("Email", "Email Sent", new string[] { success });
                    return View("GeneralMessage", message);
                }
            }
            return View();
        }
 private void SendEmail(String to, String userName, String confirmationToken)
 {
     dynamic email = new Email("Email");
     email.To = to;
     email.Username = userName;
     email.ConfirmationToken = confirmationToken;
     email.Send();
 }
Esempio n. 28
0
        public ActionResult SendFeedbackEmail2(int? id)
        {
            feedbacks feedback = db.feedbacks.Find(id);
            feedback.initiated = DateTime.Now;
            db.Entry(feedback).State = EntityState.Modified;
            db.SaveChanges();

            dynamic email = new Email("EmailExample");
            email.to = feedback.AspNetUsers.Email;
            email.Send();

            TempData["initiated_feedback"] = "Email was sent to siemens member";
            return RedirectToAction("IndexForMe", "feedbacks");
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    string confirmationToken =
                        WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email }, true);
                    dynamic email = new Email("RegEmail");
                    email.To = model.Email;
                    email.UserName = model.UserName;
                    email.ConfirmationToken = confirmationToken;
                    email.Send();

                    return RedirectToAction("RegisterStepTwo", "Account");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Esempio n. 30
0
        public ActionResult ResetPassword(ResetPasswordViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(model);
            }

            var userProfile = this.userProfileRepository.FindByEmail(model.Email);
            if (userProfile == null || !this.authentication.UserIsConfirmed(userProfile.UserName))
            {
                return this.RedirectToAction("ResetPasswordFailure");
            }

            var passwordResetToken = this.authentication.GeneratePasswordResetToken(userProfile.UserName);

            dynamic email = new Email("ResetPasswordEmail");
            email.To = userProfile.Email;
            email.DisplayName = userProfile.DisplayName;
            email.Url = this.Url.Action("ResetPasswordConfirmed", "Account", new { token = passwordResetToken }, this.Request.Url.Scheme);
            email.Send();

            return this.RedirectToAction("ResetPasswordPending");
        }
Esempio n. 31
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(model);
            }

            var emailExists = this.userProfileRepository.FindByEmail(model.Email);
            if (emailExists != null)
            {
                this.ModelState.AddModelError("", "Sorry, unable to register with this email address.");
                return this.View(model);
            }

            var mailAddress = new MailAddress(model.Email);
            var institution = this.institutionRepository.All.FirstOrDefault(i => mailAddress.Host.Contains(i.ShortName));
            if (institution == null)
            {
                this.ModelState.AddModelError("", "Sorry, the domain name in your email address does not match the name of an academic institution known to us. If you want your institution to be included in our list, please enter it’s name and web address in our contact box and we will respond promptly.");
                return this.View(model);
            }

            model.InstitutionId = institution.Id;
            model.DisplayName = model.UserName;
            model.DateRegistered = DateTime.Now;

            try
            {
                var confirmationToken = this.authentication.CreateUserAndAccount(model.UserName, model.Password, new { model.Email, model.DisplayName, model.DateRegistered, model.InstitutionId, model.OrcId });

                if (string.IsNullOrEmpty(model.AddLink))
                {
                    dynamic email = new Email("RegistrationEmail");
                    email.To = model.Email;
                    email.DisplayName = model.DisplayName;
                    email.Url = this.Url.Action("RegisterConfirmation", "Account", new { token = confirmationToken }, this.Request.Url.Scheme);
                    email.Send();

                    return this.RedirectToAction("RegistrationPending");
                }

                if (!this.Authentication.ConfirmAccount(confirmationToken))
                {
                    return this.RedirectToAction("RegisterFailure");
                }

                var loginViewModel = new LoginViewModel { Email = model.Email, Password = model.Password, RememberMe = false };

                this.Login(loginViewModel, model.AddLink);

                return this.RedirectToAction("RegisterSuccessWithLink", "Account", new { addLink = model.AddLink });
            }
            catch (MembershipCreateUserException)
            {
                this.ModelState.AddModelError("", "Can't create the user.");
            }

            return View(model);
        }
        public ActionResult SignUp(SignUpModel signUpModel)
        {
            try
            {
                if(ModelState.IsValid)
                {
                    if(!this.account.IsUserLoginIDExist(signUpModel.Email))
                    {
                        this.account.AddUserToDatabase(signUpModel);
                        FormsAuthentication.SetAuthCookie(signUpModel.Email, false);

                        var accountId = this.account.GetUserId(signUpModel.Email);

                        // Email notification
                        dynamic email = new Email("Welcome");
                        email.UserEmailAddress = signUpModel.Email;
                        email.Send();

                        return RedirectToAction("Create", "Character");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "A user with this email address already exists");
                    }
                }
            }
            catch
            {
                return View(signUpModel);
            }

            return View(signUpModel);
        }