Richard Comito
asked on
Is it Possiable to speed up CDO.Message.
I have the following code that sends out about 22,000 Emails. However it send the emails at about 1 every 5 sec or so. If I turn on my Norton it will go faster but then I use up 100% of my processor sending them out. Is there a way to speed this up or is the slow down in my code. The Email that is generated is about 200KB. I pull all the information from the Database and build most of the email in a separate class then I add it to a string. I then concatenate the string and add in small amount of changes to the Salutation and Unsubscribe button.
Any advice would be helpful.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Dim objEmailHeader As wklyEmail = New wklyEmail
Dim strEmailHeader As String = objEmailHeader.emailHeader
Dim strEmailSubscribe As String = objEmailHeader.emailSubscr ibe
Dim strEmailFooter As String = objEmailHeader.emailFooter
Dim strEmailBody As String = objEmailHeader.emailBody
Dim strEmailBody1 As String = objEmailHeader.emailBody1
Dim strEmailBody2 As String = objEmailHeader.emailBody2
Dim strEmailBody3 As String = objEmailHeader.emailBody3
Dim rsEmailList As ADODB.Recordset = objEmailHeader.rsEmailList
Dim rsEmailCount As ADODB.Recordset = objEmailHeader.emailCount
Dim strTopEmail As String
Dim strBottomEmail As String
strTopEmail = strEmailHeader + strEmailBody1
strBottomEmail = strEmailBody2 + strEmailBody3 + strEmailBody
If rsEmailList.EOF Then
MsgBox("The Email List was Empty.")
GoTo lastline
Else
Me.lblEmailTotal.Text = rsEmailCount("EmailCount") .Value
Dim n As Integer
Dim m As Integer
n = 0
m = 0
' Finish building email and sending
Do
Dim strName As String
If Not IsDBNull(rsEmailList("fldF irstName") .Value) Then
strName = rsEmailList("fldFirstName" ).Value
Else
strName = "0"
End If
'adding name and id to Salutation and Unsubscribe.
Dim strEmailSalutation As String = objEmailHeader.emailSaluta tion(strNa me)
Dim strEmailUnsubScribe As String = objEmailHeader.emailUnsubs cribe(rsEm ailList("i dEmailServ ice").Valu e)
'add Email for the Wkly Email to the email object
newMail.Body = strTopEmail + strEmailHeader + strBottomEmail + strEmailUnsubScribe + strEmailFooter
n = n + 1
'Adding new EmailAddress to the email.
newMail.To = rsEmailList("fldEmailAddre ss").Value
Try
mailServer.Send(newMail)
Catch c As Exception
MessageBox.Show(c.InnerExc eption.Inn erExceptio n.ToString ())
End Try
' update Database the email has been sent
Dim cmdUpdateEmail As New ADODB.Command
cmdUpdateEmail.CommandText = "updateEmailService"
cmdUpdateEmail.CommandType = ADODB.CommandTypeEnum.adCm dStoredPro c
cmdUpdateEmail.ActiveConne ction = objConn
cmdUpdateEmail.Parameters. Append(cmd UpdateEmai l.CreatePa rameter("@ idEmailSer vice", ADODB.DataTypeEnum.adInteg er, ADODB.ParameterDirectionEn um.adParam Input, 4, rsEmailList("idEmailServic e").Value) )
cmdUpdateEmail.Execute()
' updating form's email counter.
Me.lblEmailNeed.Text = Me.lblEmailTotal.Text - n
Me.lblCount.Text = n
rsEmailList.MoveNext()
Loop Until rsEmailList.EOF
-------------------------- ---------- ---------- ---------- ---------- ---------- ----------
Any advice would be helpful.
--------------------------
Dim objEmailHeader As wklyEmail = New wklyEmail
Dim strEmailHeader As String = objEmailHeader.emailHeader
Dim strEmailSubscribe As String = objEmailHeader.emailSubscr
Dim strEmailFooter As String = objEmailHeader.emailFooter
Dim strEmailBody As String = objEmailHeader.emailBody
Dim strEmailBody1 As String = objEmailHeader.emailBody1
Dim strEmailBody2 As String = objEmailHeader.emailBody2
Dim strEmailBody3 As String = objEmailHeader.emailBody3
Dim rsEmailList As ADODB.Recordset = objEmailHeader.rsEmailList
Dim rsEmailCount As ADODB.Recordset = objEmailHeader.emailCount
Dim strTopEmail As String
Dim strBottomEmail As String
strTopEmail = strEmailHeader + strEmailBody1
strBottomEmail = strEmailBody2 + strEmailBody3 + strEmailBody
If rsEmailList.EOF Then
MsgBox("The Email List was Empty.")
GoTo lastline
Else
Me.lblEmailTotal.Text = rsEmailCount("EmailCount")
Dim n As Integer
Dim m As Integer
n = 0
m = 0
' Finish building email and sending
Do
Dim strName As String
If Not IsDBNull(rsEmailList("fldF
strName = rsEmailList("fldFirstName"
Else
strName = "0"
End If
'adding name and id to Salutation and Unsubscribe.
Dim strEmailSalutation As String = objEmailHeader.emailSaluta
Dim strEmailUnsubScribe As String = objEmailHeader.emailUnsubs
'add Email for the Wkly Email to the email object
newMail.Body = strTopEmail + strEmailHeader + strBottomEmail + strEmailUnsubScribe + strEmailFooter
n = n + 1
'Adding new EmailAddress to the email.
newMail.To = rsEmailList("fldEmailAddre
Try
mailServer.Send(newMail)
Catch c As Exception
MessageBox.Show(c.InnerExc
End Try
' update Database the email has been sent
Dim cmdUpdateEmail As New ADODB.Command
cmdUpdateEmail.CommandText
cmdUpdateEmail.CommandType
cmdUpdateEmail.ActiveConne
cmdUpdateEmail.Parameters.
cmdUpdateEmail.Execute()
' updating form's email counter.
Me.lblEmailNeed.Text = Me.lblEmailTotal.Text - n
Me.lblCount.Text = n
rsEmailList.MoveNext()
Loop Until rsEmailList.EOF
--------------------------
ASKER
Good suggestion, but I have each email personalized. From what I am reading I need to use a third party dll. If that is true then where would I find a third party dll?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No I am on a T-1 and with no attachments. I send out pure html text. What I am tring to figure out is how other Listserv programs can send out the same type of files and not have the same type of dealy. I was reading on VBCity that CDO.message is a wrapper for the old CDONTS and the Authanticating with the exchange server is where the slow down is coming from. I have found a way to use Norton and have Norton scan the files before it is sent without showing me the progress. With that work around I am no able to send about 1000 emails every 10 minutes and Norton is now only using 50% of my proccessor and not the full 100% as it was at first. But I would think that if other programs can do this why can't I.
Glom, Thanks for your help and am looking forward to your comments.
Glom, Thanks for your help and am looking forward to your comments.
Have you tried to put more than one recipient in the newMail.To property, seperated by commas ? That would make grouped sendings and improve the speed of your App.
Tip : If you don't want the recipient to see the other recipients, use newMail.Bcc instead of newMail.To.
Bye