Beispiel #1
0
        /// <summary>
        /// Sends the registration confirmation e-mail
        /// </summary>
        public void SendRegistrationConfirmation(SendCompletedDelegate sendCompleted)
        {
            if (!string.IsNullOrEmpty(EmailAddress))
            {
                string body = string.Format(
                    @"Your registration on ibamonitoring.org has been received with the following information: 

First Name: {0}
Last Name: {1}
E-mail Address: {2}
Phone Number: {3}
Address 1: {4}
Address 2: {5}
City: {6}
State: {7}
Zip Code: {8}
OpenID: {9}

While this account remains in a pending state, you will not be able to login to the website. A site administrator must activate your account, at which time you will receive a second e-mail confirming account activation.

Please do not respond to this e-mail address.
", FirstName, LastName, EmailAddress, PhoneNumber, Address1, Address2, City, State, ZipCode, OpenId);

                string fromAddress = Settings.Default.ConfirmationEmailAddress;
                string bccAddress  = Settings.Default.AdminEmailAddress;
                string subject     = "ibamonitoring.org Registration Confirmation";

                SendEmail(body, fromAddress, bccAddress, subject, sendCompleted);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sends the activation confirmation e-mail
        /// </summary>
        public void SendActivationConfirmation(SendCompletedDelegate sendCompleted)
        {
            if (!string.IsNullOrEmpty(EmailAddress))
            {
                string body = string.Format(
                    @"Your account on ibamonitoring.org has been activated with OpenID {0}. You can now login and submit observations or update your profile.

Please do not respond to this e-mail address.", OpenId);

                string fromAddress = Settings.Default.ConfirmationEmailAddress;
                string bccAddress  = Settings.Default.AdminEmailAddress;
                string subject     = "ibamonitoring.org Activation Confirmation";

                SendEmail(body, fromAddress, bccAddress, subject, sendCompleted);
            }
        }
Beispiel #3
0
 protected override void SendEmail(string body, string fromAddress, string bccAddress, string subject, SendCompletedDelegate sendCompleted)
 {
     Assert.IsFalse(string.IsNullOrWhiteSpace(body), "body is null, whitespace, or empty");
     Assert.IsFalse(string.IsNullOrWhiteSpace(fromAddress), "fromAddress is null, whitespace, or empty");
     Assert.IsFalse(string.IsNullOrWhiteSpace(bccAddress), "bccAddress is null, whitespace, or empty");
     Assert.IsFalse(string.IsNullOrWhiteSpace(subject), "subject is null, whitespace, or empty");
 }
Beispiel #4
0
        /// <summary>
        /// Sends the email.
        /// </summary>
        /// <param name="body">The body.</param>
        /// <param name="fromAddress">From address.</param>
        /// <param name="bccAddress">The BCC address.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="sendCompleted">The send completed.</param>
        protected virtual void SendEmail(string body, string fromAddress, string bccAddress, string subject, SendCompletedDelegate sendCompleted)
        {
            // Send e-mail in a separate thread in order to keep the web site responsive.
            try
            {
                MailMessage message = new MailMessage();
                message.From = new MailAddress(fromAddress);
                message.To.Add(new MailAddress(EmailAddress));
                message.Bcc.Add(new MailAddress(bccAddress));
                message.Subject = subject;
                message.Body    = body;

                SmtpClient smtp = new SmtpClient();
                smtp.SendCompleted += new SendCompletedEventHandler(sendCompleted);

                smtp.SendAsync(message, subject);
            }
            catch (SmtpFailedRecipientException)
            {
                // Well, not much we can do about that
            }
            catch (SmtpException smtpException)
            {
                Logger.Error(smtpException);
            }
            catch (ArgumentNullException argumentNullException)
            {
                Logger.Error(argumentNullException);
            }
            catch (InvalidOperationException argumentNullException)
            {
                Logger.Error(argumentNullException);
            }
        }