PasswordRecovery and programmatically setting mailSettings
-
Hi. Is it possible to set the SMTP settings for the PasswordRecovery control from code rather than having it in the web.config file (in the System.Net -> mailSettings element)? I use the same code for several different applications and I want the e-mails to come from the various application e-mail address rather than just one hard-coded in the web.config file. I would like to set the SMTP server, username, password, etc. in the Page_Load() event, for example. None of the docs or Google hits I found addressed this for the PasswordRecovery control. I found examples of sending generic e-mails, but none address the PasswordRecovery control. Thanks! Barry Etter
-
Hi. Is it possible to set the SMTP settings for the PasswordRecovery control from code rather than having it in the web.config file (in the System.Net -> mailSettings element)? I use the same code for several different applications and I want the e-mails to come from the various application e-mail address rather than just one hard-coded in the web.config file. I would like to set the SMTP server, username, password, etc. in the Page_Load() event, for example. None of the docs or Google hits I found addressed this for the PasswordRecovery control. I found examples of sending generic e-mails, but none address the PasswordRecovery control. Thanks! Barry Etter
I think I see what you mean. You can set a bunch of subproperties of the
MailDefinition
object in code from Page_Load(), but you can't specify the server. AndMailDefinition
is read-only, so you can't create a different one. You could always handle emailing the password manually, and construct a MailMessage yourself instead of using the PasswordRecovery's built-in email capability, using an SmtpClient object to send it.