Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SamC
White Water Yakist
3467 Posts |
Posted - 2003-07-22 : 10:51:18
|
This DTS loop do until objRs.EOF ' Loop through the emails dim objMail Set objMail = CreateObject("CDONTS.NewMail") objMail.MailFormat = 0 objMail.SetLocaleIDs(65001) objMail.From = objRs("EmailFrom") objMail.To = objRs("EmailTo") objMail.Cc = objRs("EmailCc") objMail.Bcc = objRs("EmailBcc") objMail.Subject = objRs("EmailSubject") objMail.Body = objRs("EmailBody") objMail.Send Set objMail = nothing objRS.movenext loopSends email from a database.I keep looking at the CDONTS.Newmail create in the middle of the loop and wonder if it would work and be more efficent to create a single instance outside the loop, repeatedly redefine the values in the loop, send the email, then destroy the CDONTS.Newmail on loop exit?Sam |
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2003-07-22 : 11:03:35
|
It's better programming practice to create the object once rather than repeatedly, yes, and it should work. I imagine the performance gain will be slight though b/c there's not a lot involved in sending email generally, so I'm guessing the object creation doesn't involve a lot of work. I would be interested in hearing the empirical results before and after.Jonathan{0} |
 |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-07-22 : 11:07:35
|
I don't have any tool that would measure a performance improvement. I'm just irked by the constant creation and destruction inside the loop.I'll give it a try.Sam |
 |
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2003-07-22 : 11:26:50
|
quote: I don't have any tool that would measure a performance improvement
Of course you do - DTS! Make sure the package execution is logged and review the execution times of the step coded both ways.Jonathan{0} |
 |
|
|
|
|