public static String RequestPassword(object sender, System.Web.UI.WebControls.MailMessageEventArgs e, String username, String sourcePage)
        {
            String message;
            String log_text = "";

            username = HttpContext.Current.Server.HtmlEncode(username);
            try
            {
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
                smtp.EnableSsl = true;
                smtp.Send(e.Message);

                message  = "The login credentials for the specified username have been sent to the e-mail address associated with the account and should arrive shortly.";
                log_text = "Successfully Requested Password for username " + username;
            }
            catch (Exception r)
            {
                message  = "Error requesting password for username " + username + ". Please try again!";
                log_text = "Error requesting password for username " + username + Environment.NewLine + " " + r.Message + " " + r.StackTrace;
            }
            finally
            {
                Util.WriteLogWithDetails(log_text + " [Requested from " + sourcePage + "]", "requestpassword_log");
                e.Cancel = true;
            }
            return(message);
        }
        protected void cp1_SendingMail(object sender, System.Web.UI.WebControls.MailMessageEventArgs e)
        {
            // By default the ChangePassword control will use the mail settings in web.config. But since Gallery Server allows setting the
            // SMTP server and port as a gallery setting, the user might not have configured web.config, resulting in a failed e-mail.
            // To prevent this, we'll send our own e-mail, then cancel the original one.
            EmailController.SendNotificationEmail(UserController.GetUser(), Entity.EmailTemplateForm.UserNotificationPasswordChanged, GalleryId);

            e.Cancel = true;
        }