Solved

troubleshooting sending email via SMTP sometimes duplicates

Posted on 2011-02-18
13
838 Views
Last Modified: 2012-05-11
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
with Email
  .From = "me@domain.com"
  .To = .ToAdd(New MailAddress("recip@domain.com"))
  .Subject = strX
  .Body = strY
end with
SMTP.Send(Email)
Email = nothing
next item in recordset
SMTP = nothing

Open in new window

0
Comment
Question by:GordonPrince
13 Comments
 
LVL 2

Assisted Solution

by:wsewasim
wsewasim earned 100 total points
ID: 34927361

Try and test from other demo third party software same issue occurs
0
 
LVL 13

Assisted Solution

by:agarwalrahul
agarwalrahul earned 100 total points
ID: 34927396
Just try this from gmail smtp server (smtp.gmail.com) for testing purpose only if this happens again then there is a problem in the code otherwise check the exchange server settings.
0
 
LVL 4

Author Comment

by:GordonPrince
ID: 34929763
I don't think there's anything in the code. During the development of the VB 2008 version I sent about 200 messages through a different SMTP server -- no duplicates. So how would I troubleshoot the problem of two different code methods for sending email cause duplications in the production server?
0
 
LVL 4

Author Comment

by:GordonPrince
ID: 34932536
I'm assuming there's no reason I couldn't just use another SMTP server that is external to the network to send these emails, right? It is sub-optimal to send all the emails outside the office to an external SMTP server that will then send the messages back into the office to the individual recipients. But it would work, right? And that would be a way to prove that the problem is in the internal exchange server that's doing the SMTP work, right? Am Ithinking about this correctly?
0
 
LVL 12

Accepted Solution

by:
Hairbrush earned 300 total points
ID: 34941534
Does running this help? http://www.microsoft.com/downloads/en/details.aspx?familyid=bc1881c7-925d-4a29-bd42-71e8563c80a9&displaylang=en

Is your app running on the server itself?

Or do you have access to the Exchange server?  If so you could try using some diagnostic tools e.g. http://www.msexchange.org/tutorials/Exchange-2003-Message-Tracking-Logging.html
0
 
LVL 4

Author Comment

by:GordonPrince
ID: 34942679
The SMTP diagnostics uncovered some red (trouble) areas. I'm going to try getting those fixed today or tomorrow, then see how things behave. Thanks.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Author Comment

by:GordonPrince
ID: 34951790
The network admin added MX and A records and now there are no red action items in the SMTP diagnostics. But out of 13 items programmatically sent via SMTP this morning, 3 of them show up duplicated. (There's a BCC on everything that gets sent, so it's easy to spot the duplicates).

The other logging tools seem to be ways to find messages that are stuck in the queue and aren't getting delivered. I'm sure sure how to read the results to figure out what's causing messages to be sent multiple times (one of them 2 weeks ago was sent 15 times).

Any other ideas or more specific details greatly appreciated.
0
 
LVL 12

Expert Comment

by:Hairbrush
ID: 34952175
Hi, I suggest you contact a moderator and ask them to make the following changes to the question:

Change primary zone to Microsoft Exchange Server;
Add to "SMTP" zone.

I think this will help channel the question to the most appropriate experts.
0
 
LVL 4

Author Comment

by:GordonPrince
ID: 34970607
agarw -- what credentials would I use with smtp.gmail.com?
0
 
LVL 4

Author Comment

by:GordonPrince
ID: 34970621
agarw -- I mean, what's the format of the credentials. I have a gmail account, I assume I would use that. I just can't get the code to set my credentials in a way that allows a test message to be sent.
0
 
LVL 4

Author Comment

by:GordonPrince
ID: 34978802
After quite a bit of testing, I may have uncovered the problem. I was able to create a database item that consistently resulted in duplicate emails being sent. One of the recipients was an email address for a group. After changing the members of the group and having the duplicates come and go (but be consistent over several runs when the members of the group were the same), I looked at the group in Active Directory. It was set as a Security type group, not a Distribution type group. When I changed it to be a Distribution type group, the duplicates stopped, regardless of who the members of the group were. This morning I've had a large production run of items and no duplicates. So maybe that's what it was. I wouldn't have thought this should cause the problem, but maybe there was some corruption in the Security group and changing it to Distribution group rebuilt the group as the new type, or something like that. But for now, it appears this may be it. Although this is not definitive, as the problem seemed intermittent, until I was able to find a test item that failed every time.
0
 
LVL 12

Expert Comment

by:Hairbrush
ID: 34978974
Glad you appear to have it sorted.
0
 
LVL 4

Author Comment

by:GordonPrince
ID: 35029384
Turns out the problem I found is not the only problem. I've had other duplications in some of the emails since then. But with those when I tried resending the items, they didn't duplicate. I've learned from the network administrator that there are other emails that are getting duplicated, in addition to the ones I'm sending. So there's something wrong with the email system. Thanks to all for the ideas on this.
0

Featured Post

Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now