I'm using VB 2008 to send email messages as shown below with an Exchange 2003 Server. About one message in 10 gets sent multiple times. This has been going on for over a month now. How can I fix this problem?
The original program was written in VB6 using CDO to send the messages. It worked for 5+ years, then started having the trouble about two months ago. I've just finished upgrading it to VB2008 with the techniques shown in the code example window, sent 20 emails this morning and three of them were sent twice.
I've tried resending the messages that duplicated themselves and they usually don't duplicate themselves. Sending the same message 10 different times only results in a duplication 0-2 times. I can't find a pattern. One message last week had 6 recipients on it and they each got 15 copies of the message. But then over the next few days 40-50 messages were sent with no duplicates. Now I've got some duplicates again this morning.
Any ideas how to troubleshoot this problem?
Dim Email As MailMessage, SMTP As New SmtpClient
' first, set the SMTP properties
for each item in the recordset
Email = new MailMessage
.From = "firstname.lastname@example.org"
.To = .ToAdd(New MailAddress("email@example.com"))
.Subject = strX
.Body = strY
Email = nothing
next item in recordset
SMTP = nothing