Saturday, March 10, 2007

How To: Implement your email sending with the asp:PasswordRecovery control

after a while i finally figured out what i have missed to prevent emails to sent twice - once over the control and once over my own logic.

Markup:

<asp:PasswordRecovery
ID="PasswordRecovery"
runat="server"
OnSendingMail="PasswordRecovery_SendingMail"


Code Behind:

protected void PasswordRecovery_SendingMail(object sender, MailMessageEventArgs e)
{
e.Cancel = true;
e.Message.Dispose();

.. here my own logic starts.
}

in the web.config file you need minimum the following configuration:

<system.net>
 <mailsettings>
  <smtp from="your email address">
 </mailsettings>
 </system.net>
</configuration>

.. evoila.. that's all - happy email sending.

No comments:

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge