public void SendPasswordToUser()
        {
            // use Assignment Manager sysadmin email
            UserM  amsaUser     = UserM.Load(Constants.ASSIGNMENTMANAGER_SYSTEM_ADMIN_USERID);
            string sentByEmail  = amsaUser.EmailAddress;
            string emailSubject = SharedSupport.GetLocalizedString("User_EmailSubject");

            string[] replacements = new string[2] {
                this._username, this._password
            };
            string emailBody = SharedSupport.GetLocalizedString("User_EmailBody", replacements);

            MessageM.SendMessage(sentByEmail, this._emailAddress, emailSubject, emailBody);
        }
        public static void sendEmailMessageToCourse(string subject, string body, string link, int courseId)
        {
            if (!Convert.ToBoolean(SharedSupport.UsingSmtp))
            {
                throw (new System.Exception(SharedSupport.GetLocalizedString("Global_NoSMTP")));
            }

            try
            {
                // validation
                if (body.Equals(String.Empty))
                {
                    throw new  ArgumentException(SharedSupport.GetLocalizedString("SendEmailMessage_InvalidBody"));
                }
                if (subject.Equals(String.Empty))
                {
                    throw new  ArgumentException(SharedSupport.GetLocalizedString("SendEmailMessage_InvalidSubject"));
                }

                string mailTo          = "";
                System.Data.DataSet ds = new System.Data.DataSet();

                //use generic Assignment Manager From
                string sentByEmail = string.Empty;

                UserList ul      = UserList.GetListFromCourse(courseId);
                int[]    userIDs = ul.UserIDList;
                for (int i = 0; i < userIDs.Length; i++)
                {
                    UserM user = UserM.Load(userIDs[i]);
                    mailTo += user.EmailAddress + ";";
                }

                // use Assignment Manager sysadmin email
                UserM amsaUser = UserM.Load(Constants.ASSIGNMENTMANAGER_SYSTEM_ADMIN_USERID);
                sentByEmail = amsaUser.EmailAddress;

                // add the formatting and action link
                body += "\n" + "\n" + link;

                // send email
                SendMessage(sentByEmail, mailTo, subject, body);
            }
            catch (System.Exception ex)
            {
                SharedSupport.HandleError(ex);
            }
        }
        public void SendNotifications(object sender, System.Timers.ElapsedEventArgs args)
        {
            // disable the timer
            timer.Enabled = false;

            try
            {
                // use Assignment Manager sysadmin email
                UserM  amsaUser    = UserM.Load(Constants.ASSIGNMENTMANAGER_SYSTEM_ADMIN_USERID);
                string sentByEmail = amsaUser.EmailAddress;

                System.Data.DataSet dsAssignmentList = new System.Data.DataSet();
                DatabaseCall        dbc = new DatabaseCall("Notifications_GetAssignmentList", DBCallType.Select);
                dbc.Fill(dsAssignmentList);
                if (dsAssignmentList.Tables[0].Rows.Count <= 0)
                {
                    return;
                }

                for (int j = 0; j < dsAssignmentList.Tables[0].Rows.Count; j++)
                {
                    int assignmentID = Convert.ToInt32(dsAssignmentList.Tables[0].Rows[j]["AssignmentID"]);
                    // send the notifications
                    try
                    {
                        //////////////////////////////////////////////////////////////////////
                        /// Past Due Notifications
                        //////////////////////////////////////////////////////////////////////
                        System.Data.DataSet ds = new System.Data.DataSet();
                        dbc = new DatabaseCall("Notifications_BrowsePastDueNotifications", DBCallType.Select);
                        dbc.AddParameter("AssignmentID", assignmentID);
                        dbc.Fill(ds);

                        if (ds.Tables[0].Rows.Count <= 0)
                        {
                            continue;
                        }

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            if (ds.Tables[0].Rows[i]["AssignmentID"] != DBNull.Value)
                            {
                                string   assignName     = ds.Tables[0].Rows[i]["ShortName"].ToString();
                                DateTime dueDate        = Convert.ToDateTime(ds.Tables[0].Rows[i]["DueDate"]);
                                string[] AssignmentInfo = new string[] { assignName, string.Format("{0:d}", dueDate) };

                                string pastDueSubject  = SharedSupport.GetLocalizedString("Notification_PastDueSubject", AssignmentInfo);
                                string pastDueBody     = SharedSupport.GetLocalizedString("Notification_PastDueBody", AssignmentInfo);
                                string reminderSubject = SharedSupport.GetLocalizedString("Notification_ReminderSubject", AssignmentInfo);
                                string reminderBody    = SharedSupport.GetLocalizedString("Notification_ReminderBody", AssignmentInfo);

                                TimeSpan difference = dueDate - DateTime.Today;
                                if (Convert.ToBoolean(ds.Tables[0].Rows[i]["SendPastDue"]) &&
                                    (difference.Days == -1 * Convert.ToInt32(ds.Tables[0].Rows[i]["PastDueWarningDays"])))
                                {
                                    UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"]));
                                    MessageM.SendMessage(sentByEmail, user.EmailAddress, pastDueSubject, pastDueBody);
                                }

                                if (Convert.ToBoolean(ds.Tables[0].Rows[i]["SendReminders"]) &&
                                    (difference.Days == Convert.ToInt32(ds.Tables[0].Rows[i]["ReminderWarningDays"])))
                                {
                                    UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"]));
                                    MessageM.SendMessage(sentByEmail, user.EmailAddress, reminderSubject, reminderBody);
                                }
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        SharedSupport.HandleError(ex);
                    }
                }
            }
            catch (System.Exception ex)
            {
                SharedSupport.HandleError(ex);
            }
            finally
            {
                // reset the interval for the next event
                timer.Interval = millisecondsToMidnight();

                // re-enable the timer
                timer.Enabled = true;
            }
        }