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

L

Luc

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: (e-mail address removed) . 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
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top