Ejemplo n.º 1
0
        public void SendEmail(ApplicationUser applicationUser)
        {
            var userName = applicationUser.FirstName + " " + applicationUser.PrimaryName;
            var message  = new MimeMessage();

            message.From.Add(new MailboxAddress("TODO App - Reminder", EmailConstants.EmailAddress));
            message.To.Add(new MailboxAddress(userName, applicationUser.Email));
            message.Subject = "You have unfinished task(s), deadline is today!!!";

            message.Body = new TextPart(TextFormat.Html)
            {
                Text = "Hey " + userName + ",\n" +

                       "You have unfinished task and the dead line is today, please complete the task."
            };

            using (var client = new SmtpClient())
            {
                client.Connect("smtp.gmail.com", 587, false);

                var password = passwordManager.Decrypt(EmailConstants.EmailPasswordEncrypted, EmailConstants.EmailPasswordKey);
                client.Authenticate(EmailConstants.EmailAddress, password);

                client.Send(message);
                client.Disconnect(true);
            }
        }