?
Solved

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

Posted on 2012-09-13
1
Medium Priority
?
498 Views
Last Modified: 2012-09-14
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
Comment
Question by:MVaughn12
1 Comment
 

Accepted Solution

by:
MVaughn12 earned 0 total points
ID: 38398965
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

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question