예제 #1
0
        public void Send(TaskReminder reminder)
        {
            var message = _translator.Translate(reminder);

            using (var client = new SmtpClient())
            {

                //_smtpDetails = new SmtpDetails()
                //{
                //    Server = "smtp.friends.com",
                //    Port = 587,
                //    UserName = "******",
                //    Password = "******"
                //};


                client.Connect(_smtpDetails.Server, _smtpDetails.Port, false);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove("XOAUTH2");

                // Note: only needed if the SMTP server requires authentication
                client.Authenticate(_smtpDetails.UserName, _smtpDetails.Password);

                client.Send(message);
                client.Disconnect(true);
            }
        }
예제 #2
0
 public Mail Translate(TaskReminder taskReminder)
 {
     var mail = Mail.GetInstance();
     mail.AddTo(taskReminder.ReminderTo);
     mail.AddCc(taskReminder.CopyReminderTo);
     mail.Subject = string.Format("Task Reminder! Task {0} is due on {1}", taskReminder.TaskName, taskReminder.DueDate);
     return mail;
 }
예제 #3
0
        public void Send(TaskReminder reminder)
        {
            var mail = _translator.Translate(reminder);

            var credentials = new NetworkCredential(
                ConfigurationManager.AppSettings["sendGridUserName"],
                ConfigurationManager.AppSettings["sendGridPassword"]
                );

            var api = Web.GetInstance(credentials);

            api.DeliverAsync(mail).Wait();
        }
예제 #4
0
        public MimeMessage Translate(TaskReminder taskReminder)
        {
            var message = new MimeMessage();
            message.From.Add(new MailboxAddress("Tasks Reminder", "*****@*****.**"));
            message.To.Add(new MailboxAddress(taskReminder.ReminderTo, taskReminder.ReminderTo));
            message.Cc.Add(new MailboxAddress(taskReminder.CopyReminderTo, taskReminder.CopyReminderTo));
            message.Subject = string.Format("Task Reminder! Task {0} is due on {1}", taskReminder.TaskName,
                taskReminder.DueDate);
            message.Body = new TextPart("plain")
            {
                Text = string.Format("Task {0} is due on {1}", taskReminder.TaskName, taskReminder.DueDate)
            };

            return message;
        }