asp:passwordrecovery System.Net.Mail.SmtpFailedRecipientException

Discussion in 'ASP .Net Web Services' started by malhenry, Feb 28, 2007.

  1. malhenry

    malhenry Guest

    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.
     
    malhenry, Feb 28, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arjen
    Replies:
    0
    Views:
    589
    Arjen
    Jun 6, 2005
  2. Brad
    Replies:
    2
    Views:
    11,036
  3. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    System.Net.Mail vs System.Web.Mail

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jun 16, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,652
    Walter Wang [MSFT]
    Jun 16, 2006
  4. Fabio Visin
    Replies:
    4
    Views:
    2,558
    Steven Cheng[MSFT]
    Apr 18, 2007
  5. Velvet
    Replies:
    0
    Views:
    429
    Velvet
    Sep 11, 2008
Loading...

Share This Page