I used excel file with 103 records with email and name columns to send out emails using vb.net 2010.
I created sql server linked server to get excel data and sql server procedure simple as select * from LinkName...MydataSheet
Worked perfect in sql query window. 103 records.
In my vb code I populate data table (dt) with this data using the procedure and use the loop to go to each record, get email address from the field and send email, something like this:
for i = 1 to dt.rows.count - 1
'code to send email to this address
when debugging it goes 102 times and exits the loop.
However each email box from the file got all other 102 emails with another addresses!!!!
so for instance I have 3 records:
so a,b,c got each all 3 emails!
I used that code before many times and it never failed me like that! I couldn't find the problem while debugging. The only difference between previous projects and this one is the data source. Usually I use sql server table and not excel. So I dumped the data to the sql server table and it worked correctly, no more multiple emails. Each email address got it's own email.
I then looked at the excel file, checked for anything that might have caused that strange behavior and found no formulas, no macros, just one file with 103 records on the first sheet.
Can you please help me to shed some light what happens when excel used and why it generates emails that are NOT coming out from the code when debugging????!!!!