why is the mail not sent?

A

Albert

Hi,

i want to create users with the control CreateUserWizard, but by only
entering the username. That's why i use the property RequireEmail="false" of
CreateUserWizard. In the CreateUserWizard1_CreatedUser event, the
emailaddress is then programmatically made by adding "@xxx.zz" to the
username and put in the aspnet_membership table (with an update).

Now, when i use requiresUniqueEmail="true" in <membership> of web.config, i
get the error: "please enter a valid emailaddress".
When i use requiresUniqueEmail="false", i can see that the emailaddress is
correctly put into the table aspnet_membership, but the event
CreateUserWizard1_SendingMail is never fired (checked with
response.write("mail sent!")).

Thanks for help
Albert


Here the aspx code:
------------------
<asp:CreateUserWizard ID="CreateUserWizard1" RequireEmail="false"
AutoGeneratePassword="true" runat="server" >

<MailDefinition IsBodyHtml="true" BodyFileName="pw.txt"
From="(e-mail address removed)"
Subject="your password" />

<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<asp:Label ID="UserNameLabel" Text="user:" runat="server">
</asp:Label>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>

</asp:CreateUserWizard>

code-behind:
-----------
Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e
As System.EventArgs) Handles CreateUserWizard1.CreatedUser
...
comd.Connection = connection
comd.CommandText = "UPDATE aspnet_Membership SET Email = @txem ....
....
comd.ExecuteNonQuery()
connection.Close()
End Sub

Protected Sub CreateUserWizard1_SendingMail(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.MailMessageEventArgs) Handles
CreateUserWizard1.SendingMail
respnse.write("mail sent")
e.Message.Body = e.Message.Body.Replace("##user##",
CreateUserWizard1.UserName)
e.Message.Body = e.Message.Body.Replace("##password##",
CreateUserWizard1.Password)
'attention ##...## est case-sensitive
e.Message.Body = e.Message.Body.Replace("##url##",
"http://myserver/enqit/login.aspx")
End Sub


web.config:
-----------
<membership>
<providers>
<remove name="AspNetSqlMembershipProvider"/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="enquete"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
passwordStrengthRegularExpression=""/>
</providers>
</membership>

<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="(e-mail address removed)">
<network host="myprovider.bn.rr" port="25"/>
</smtp>
</mailSettings>
</system.net>
 

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,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top