asp:passwordrecovery System.Net.Mail.SmtpFailedRecipientException

M

malhenry

Hi,

I am trying to use asp:passwordrecovery and I want to catch
System.Net.Mail.SmtpFailedRecipientException which can happen when someone
enters a bad email address in the membership? database. The email message
containing the new password can not get to the user because of the invalid
email address.

Where can I put the catch logic so that this exception does not blow up my
web app? Or is there another way to handle this situation?

here is the aspx snippet:
<div id="xxx">
<fieldset>
<!-- add H2 here and hide it with css since you can not put h2
inside a legend tag -->
<h2 class="none">
Change Password</h2>
<legend>Change Password</legend>
<asp:passwordRecovery ID="PasswordRecovery1" runat="server"
UserNameInstructionText="Enter your User Name to receive your new password
via e-mail.">
</asp:passwordRecovery>
</fieldset>
</div>

Here is the code behind:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class zzz : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// dummy stuff for failed attempt to catch exception
int i;

try
{
i = 5;
}
catch (System.Net.Mail.SmtpFailedRecipientException)
{
i = 6;
}

}
}

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top