Example #1
0
 /// <summary>
 /// Checks the reminders and sends reminders if needed.
 /// </summary>
 public void CheckReminders()
 {
     Email email = new Email();
     foreach (Task task in taskList)
     {
         if (task.reminder && task.date.AddDays(-task.daysOfReminder).Date == System.DateTime.Today.Date
             && ValidateEmail(task.reminderEmail))
         {
             if (SendReminder(task, email))
             {
                 break;
             }
         }
     }
     this.Save();
     this.SetRemindersLeft();
 }
Example #2
0
        /// <summary>
        /// Sends a reminder for the task.
        /// </summary>
        /// <param name="task">The t.</param>
        /// <param name="email">The email.</param>
        /// <returns></returns>
        private bool SendReminder(Task task, Email email)
        {
            bool reminderSucceeded = true;
            string subject = "REMINDER: " + task.tag + " - " + task.task;
            string body;

            if (task.daysOfReminder == 0)
            {
                body = "Your deadline is today, " + task.date.ToLongDateString() + " for \"" + task.tag + " - " + task.task + "\".";
            }
            else if (task.daysOfReminder == 1)
            {
                if (task.completed)
                {
                    body = "You have 1 day to until your deadline \"" + task.tag + " - " + task.task
                        + "\".\nThat is your deadline is tommorow, " + task.date.ToLongDateString() + ".";
                }
                else
                {
                    body = "You have 1 day to complete \"" + task.tag + " - " + task.task
                         + "\".\nThat is your deadline is tommorow, " + task.date.ToLongDateString() + ".";
                }
            }
            else
            {
                if (task.completed)
                {
                    body = "You have " + task.daysOfReminder.ToString() + " days to until your deadline \"" + task.tag + " - " + task.task
                        + "\".\nThat is your deadline is, " + task.date.ToLongDateString() + ".";
                }
                else
                {
                    body = "You have " + task.daysOfReminder.ToString() + " days to complete \"" + task.tag + " - " + task.task
                        + "\".\nThat is your deadline is, " + task.date.ToLongDateString() + ".";
                }
            }
            if (task.notes.Length > 0)
            {
                body += "\n\nYour notes are provided below.\n";
                body += "-----------------------------------------------\n";
                body += task.notes;
                body += "\n-----------------------------------------------";
            }
            body += "\n\nThis Message is brought to you by Task Manager.";
            email.Send(subject, body, task.reminderEmail, ref reminderSucceeded);
            if (reminderSucceeded)
            {
                task.reminder = false;
            }

            return reminderSucceeded;
        }