Link to home
Start Free TrialLog in
Avatar of Richard Comito
Richard ComitoFlag for United States of America

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.emailSubscribe
                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("fldFirstName").Value) Then
                            strName = rsEmailList("fldFirstName").Value
                        Else
                            strName = "0"
                        End If
                        'adding name and id to Salutation and Unsubscribe.
                        Dim strEmailSalutation As String = objEmailHeader.emailSalutation(strName)
                        Dim strEmailUnsubScribe As String = objEmailHeader.emailUnsubscribe(rsEmailList("idEmailService").Value)

                        '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("fldEmailAddress").Value

                        Try
                            mailServer.Send(newMail)
                        Catch c As Exception
                            MessageBox.Show(c.InnerException.InnerException.ToString())
                        End Try

                        ' update Database the email has been sent
                        Dim cmdUpdateEmail As New ADODB.Command
                        cmdUpdateEmail.CommandText = "updateEmailService"
                        cmdUpdateEmail.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
                        cmdUpdateEmail.ActiveConnection = objConn
                        cmdUpdateEmail.Parameters.Append(cmdUpdateEmail.CreateParameter("@idEmailService", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput, 4, rsEmailList("idEmailService").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



--------------------------------------------------------------------------------------
Avatar of Glom
Glom
Flag of France image

Hi,
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
Avatar of Richard Comito

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
Avatar of Glom
Glom
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.