/// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            SetPasswordRecoverControlProperties();
            MailSettings   mailSettings   = MessagingCache.GetMailSettings();
            MailDefinition mailDefinition = prPasswordRecover.MailDefinition;

            mailDefinition.From = mailSettings.From;
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Email"/> class.
 /// </summary>
 public Email()
 {
     mailSettings = MessagingCache.GetMailSettings();
     smtpClient   = new SmtpClient(mailSettings.Host, mailSettings.Port);
     if (mailSettings.RequireAuthentication)
     {
         smtpClient.Credentials = new NetworkCredential(mailSettings.UserName, mailSettings.Password);
     }
     if (mailSettings.RequireSsl)
     {
         smtpClient.EnableSsl = true;
     }
 }
        /// <summary>
        /// Handles the Click event of the btnSend control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnSend_Click(object sender, EventArgs e)
        {
            MailSettings mail        = MessagingCache.GetMailSettings(); //TODO: Cache?
            MailMessage  mailMessage = new MailMessage();

            mailMessage.From = new MailAddress(txtEmail.Text.Trim(), txtName.Text.Trim());
            mailMessage.To.Add(new MailAddress(mail.Contact));
            mailMessage.Subject    = txtSubject.Text.Trim();
            mailMessage.Body       = txtMessage.Text.Trim();
            mailMessage.IsBodyHtml = false;

            Email email = new Email();

            email.Send(mailMessage);
            lblSent.Visible = true;
        }