Exemple #1
0
        /// <summary>
        /// Construct a <code>System.Web.Mail.MailMessage</code> object from the given
        /// Swenet <code>Email</code> object and the from address.
        /// </summary>
        /// <param name="e">
        /// The email to construct the subject and body from.
        /// </param>
        /// <param name="toUsername">
        /// The destination username from which to determine the email address.
        /// </param>
        /// <param name="from">
        /// A sender's address.
        /// </param>
        /// <returns>
        /// A mail message with the subject and body of <code>e</code> and
        /// the given destination and sender addresses.</returns>
        public static MailMessage constructMailMessage(Email e, string toUsername, string from)
        {
            MailMessage retVal = null;

            if (e != null)
            {
                retVal         = new MailMessage();
                retVal.Subject = e.Subject;
                retVal.Body    = e.Body;
                UserAccounts.UserInfo user = UserAccounts.getUserInfo(toUsername);
                retVal.To   = user.Email;
                retVal.From = from;
            }

            return(retVal);
        }
Exemple #2
0
        /// <summary>
        /// Format an email message with information for the given user and module.
        /// </summary>
        /// <param name="message">
        /// The message to format.
        /// </param>
        /// <param name="username">
        /// The username whose information should be used.
        /// </param>
        /// <param name="moduleID">
        /// The module to get information for to use in formatting.
        /// </param>
        public static void formatEmail(Email message, string username, int moduleID)
        {
            UserAccounts.UserInfo user = UserAccounts.getUserInfo(username);
            message.Subject = message.Subject.Replace(Username, user.Username);
            message.Body    = message.Body.Replace(Name, user.Name);
            message.Body    = message.Body.Replace(Emails.SiteUrl, Globals.SiteUrl);
            message.Body    = message.Body.Replace(Emails.Role, user.Role.ToString());

            if (moduleID != -1)
            {
                Modules.ModuleInfo module = Modules.getModuleInfo(moduleID);
                message.Subject = message.Subject.Replace(ModuleTitle, module.Title);
                message.Body    = message.Body.Replace(ModuleTitle, module.Title);
                message.Body    = message.Body.Replace(ModuleID, moduleID.ToString());
            }
        }
Exemple #3
0
 /// <summary>
 /// Format an email message with information for the given user and password.
 /// </summary>
 /// <param name="message"></param>
 /// The message to format.
 /// <param name="username"></param>
 /// The username for the account.
 /// <param name="password"></param>
 /// The new password that has been set.
 public static void formatEmail(Email message, string username, string password)
 {
     UserAccounts.UserInfo user = UserAccounts.getUserInfo(username);
     message.Body = message.Body.Replace(Name, user.Name);
     message.Body = message.Body.Replace(Password, password);
 }