By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

Email sending twice

P: 56
Hello

My SMTP code sends a message to the user and a duplicate message to the same user at the same time. Why is that, please?

This is my SMTP code:

Expand|Select|Wrap|Line Numbers
  1. Dim myMessage As New MailMessage
  2. Dim Smtpserver As New SmtpClient
  3. Dim strEmailValue As String = Request.Form("strEmailTextBox") 'strEmailValue = user email; strEmailTextBox = ID of email field
  4.  
  5. 'Create the mail message
  6.  
  7. myMessage.From = New MailAddress("info@mysite.net") 'Webmaster's email
  8.  
  9. myMessage.To.Add(New MailAddress(strEmailValue)) 'user's email
  10.  
  11. myMessage.Subject = ("Password Reset Request")
  12.  
  13. myMessage.Body = "Please click on the following.."           
  14.  
  15. myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
  16.  
  17. myMessage.IsBodyHtml = True
  18.  
  19. myMessage.Priority = MailPriority.Normal
  20.  
  21. HTML/Plain code here
  22.  
  23. Smtpserver.DeliveryMethod = SmtpDeliveryMethod.Network
  24. Smtpserver.Host = ("IP address")
  25. Smtpserver.Port = 25
  26. Smtpserver.EnableSsl = False
  27.  
  28. Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@mysite.net", "Smtp_pwd")
  29.  
  30. Smtpserver.Credentials = basicAuthenticationInfo
  31. Smtpserver.Send(myMessage)
  32.  
  33. myMessage.Dispose()
  34. myMessage = Nothing
  35. Smtpserver = Nothing
Thanks for any advice.
Feb 25 '17 #1

✓ answered by Frinavale

Line 31 is the command that actually sends the email.
I don't see anything wrong at first glance.

Share this Question
Share on Google+
3 Replies


Frinavale
Expert Mod 5K+
P: 9,731
I recommend putting a break point on the code that sends the email so that you can check out the call stack the second time it is executed. This way you can determine why its happening.
Feb 27 '17 #2

P: 56
The whole SMTP code sends the email, doesn't it?

But at first glance you can see nothing wrong with the code?

Thank you for your reply.
Feb 27 '17 #3

Frinavale
Expert Mod 5K+
P: 9,731
Line 31 is the command that actually sends the email.
I don't see anything wrong at first glance.
Feb 28 '17 #4

Post your reply

Sign in to post your reply or Sign up for a free account.