how to prevent creating user and showing ''Mailbox unavailable' in case of wrong emailaddress?

Discussion in 'ASP .Net' started by Luc, Mar 3, 2010.

  1. Luc

    Luc Guest

    Hi,

    i use the login control in order to create users. Asp.net generates
    automatically a password which is sent to the user by email.
    The emailaddress must be like this: . I can
    easely check whether it terminates with @ourdomain.be, but if
    'firstname.name' doesn't exist in our Exchange server ('ourdomain.be'),
    then:

    1) the user is still created
    2) the message page with: 'Mailbox unavailable. The server response was:
    5.1.1 User unknown' appears

    What i want is 1) that the user is not created and 2) that a simple
    Alert-box appears instead of the this error page.

    I tried a lot of Try / Catch / Endtry but all my attempts fail: the user is
    always created and the whole message page appears. I also tried with
    CreateUserWizard1_SendMailError sub.1

    Here my code (vb.net):

    Protected Sub CreateUserWizard1_CreatingUser(ByVal sender As Object, ByVal e
    As System.Web.UI.WebControls.LoginCancelEventArgs) Handles
    CreateUserWizard1.CreatingUser
    Dim tx, em As TextBox
    tx =
    CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("username"),
    TextBox)
    em =
    CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("email"),
    TextBox)

    If Not Right(em.Text, 12) = "ourdomain.be" Then
    Label3.Text = "wrong emailaddress"
    e.Cancel = True
    End If
    End Sub
    -----------------------------------------------
    Protected Sub CreateUserWizard1_SendingMail(ByVal sender As Object,
    ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles
    CreateUserWizard1.SendingMail
    Label2.Visible = False
    e.Message.Body = e.Message.Body.Replace("##user##",
    CreateUserWizard1.UserName)
    e.Message.Body = e.Message.Body.Replace("##password##",
    CreateUserWizard1.Password)
    End Sub
    -----------------------------------------------
    Protected Sub CreateUserWizard1_SendMailError(ByVal sender As Object,
    ByVal e As System.Web.UI.WebControls.SendMailErrorEventArgs) Handles
    CreateUserWizard1.SendMailError
    Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),
    "myscript", _
    " alert(Unknown user.');", True)
    End Sub
    End Class
     
    Luc, Mar 3, 2010
    #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. Replies:
    4
    Views:
    3,590
  2. Harry Bellafonte
    Replies:
    18
    Views:
    581
    Norman Peelman
    Nov 20, 2007
  3. AAaron123
    Replies:
    1
    Views:
    1,096
    AAaron123
    Oct 6, 2008
  4. Josselin

    RFC2822::EmailAddress

    Josselin, Jan 17, 2007, in forum: Ruby
    Replies:
    4
    Views:
    125
    Dominic Marks
    Jan 17, 2007
  5. Mark 123
    Replies:
    5
    Views:
    127
    Christopher J. Hahn
    Jul 4, 2005
Loading...

Share This Page