Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CmoOpenedMessageReceipt"/> class.
 /// </summary>
 /// <param name="message">The newly posted CMO message.</param>
 /// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
 /// <exception cref="ArgumentException"><paramref name="message"/> has not been posted.</exception>
 public CmoOpenedMessageReceipt(CmoMessage message)
 {
     if (message == null)
     {
         throw new ArgumentNullException("message", "CMO message must not be null.");
     }
     _message = message;
     if (!message.IsOpened)
     {
         throw new ArgumentException("message", "CMO message must be opened first before a receipt can be sent.");
     }
     _mail         = new CPMailMessage();
     _mail.Sender  = new MailAddress(_mail.Sender.Address);
     _mail.Subject = string.Format(OpenReceiptSubjectFormat, _message.UniqueID);
     _mail.AddRecipients(message.OpenReceiptEmail);
     _mail.IsBodyHtml = true;
 }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmoPostedMessageNotice"/> class.
        /// </summary>
        /// <param name="message">The newly posted CMO message.</param>
        /// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="message"/> has not been posted.</exception>
        private CmoPostedMessageNotice(CmoMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message", "CMO message must not be null.");
            }
            _message = message;
            if (!message.IsPosted)
            {
                throw new ArgumentException("message", "CMO message must be posted first before a notification can be sent.");
            }
            _mail = new CPMailMessage();
            ISettingsProvider settings = CPProviders.SettingsProvider;

            _mail.Sender     = settings == null ? new MailAddress(_mail.Sender.Address) : new MailAddress(settings.MessageSenderEmail, settings.MessageSenderDisplayName);
            _mail.Subject    = message.Title;
            _mail.IsBodyHtml = true;
        }
Exemple #3
0
        /// <summary>
        /// Sends an e-mail notification of a password reset to a user.
        /// </summary>
        /// <param name="recipient">The user whose password is being reset.</param>
        /// <param name="password">The user's new password.</param>
        /// <exception cref="ArgumentNullException"><paramref name="recipient"/> or <paramref name="password"/> is null.</exception>
        public static void Send(CPUser recipient, SecureString password)
        {
            if (recipient == null)
            {
                throw new ArgumentNullException("recipient", "Password reset message recipient cannot be null.");
            }
            if (password == null)
            {
                throw new ArgumentNullException("password", "Password cannot be null.");
            }

            using (CPMailMessage message = new CPMailMessage()
            {
                Recipient = new MailAddress(recipient.Email, recipient.DisplayName),
                Subject = CPProviders.SettingsProvider.ApplicationName + @" Username/Password Reset",
                Body = string.Format(MessageBodyFormat, recipient.DisplayName, CPProviders.SettingsProvider.AgencyName, CPProviders.SettingsProvider.ApplicationName, CPProviders.SettingsProvider.ApplicationUrl, recipient.UserName, password.Decrypt(), CPProviders.SettingsProvider.AgencyPhoneNumber)
            })
            {
                message.Send();
                message.Body.Remove(0);
            }
        }