• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • Last Modified:

Mail.SmtpClient in createuserwizard_sendingmail event sending 2 copies of email, why?

Hello all I have a creatuserwizard on my asp.net site that fires off an email when someone registers that requires them to click a link to activate the account.  That all works fine.
I have the MailDefinition setup on the control itself that builds the body of the email, sender etc. In my webconfig I have the mailsettings for server host, port, sending user,, etc.
On the sedndingmail event I have the following code. I always get 2 copies of the email.  What am I doing wrong in teh code below that is causing it?  I can't seem to eliminate the right line.
 Dim newUserAccount As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
        Dim newUserAccountId As Guid = DirectCast(newUserAccount.ProviderUserKey, Guid)
        Dim domainName As String = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath
        Dim confirmationPage As String = "/account/EmailVerification.aspx?UserID=" & newUserAccountId.ToString()
        Dim url As String = domainName & confirmationPage
        e.Message.Body = e.Message.Body.Replace("<%VerificationUrl%>", url)
        Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
        Dim Mailmsg As New System.Net.Mail.MailMessage
        obj.EnableSsl = True
        'ADD ADDRESSES, SUBJECT, BODY
        obj.Send(e.Message)
        e.Cancel = True
0
MVaughn12
Asked:
MVaughn12
1 Solution
 
MVaughn12Author Commented:
Well I got it working found a post out on the web that had the same issue on a button click, but using similar code. I took the Handles CreateUserWizard1.SendingMail out of my code and user now only gets 1 copy of the email.  Code must have been firing twice?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Tackle projects and never again get stuck behind a technical roadblock.
Join Now