Link to home
Start Free TrialLog in
Avatar of jasonlassen
jasonlassen

asked on

Sending email using CDO from VB6 app is slow

I have a simple VB6 app that uses CDO to send email.  It's worked perfectly for the past 2 years.  A few days ago, it began having  speed issues.  Rather than sending multiple emails in less than a second, it now takes 5-10 seconds to send a single email.  The code hangs on the .Send command.
To my knowledge, there have been no changes made to our network over the past week.  I've checked patch logs, asked if anyone made any Group Policy changes, software installs - nothing changed recently.  
The .send command works, but way too slow.
Any ideas here?
Dim Cdo2Configuration As cdo.Configuration
    Dim Cdo2Message As cdo.Message
    Dim Cdo2Fields As ADODB.Fields
    
    Set Cdo2Configuration = New cdo.Configuration
    Set Cdo2Fields = Cdo2Configuration.Fields
    With Cdo2Fields
      .Item(cdoSMTPServer) = "Exchange_Server_Name"
      .Item(cdoSendUsingMethod) = cdoSendUsingPort
      .Item(cdoSMTPConnectionTimeout) = 15
      .Update ' Important
    End With
    
    ' Create a new message.
    Set Cdo2Message = New cdo.Message
    
    ' Set the message's configuration.
    Set Cdo2Message.Configuration = Cdo2Configuration
    
    ' Set the message content.
    Cdo2Message.Subject = sSubject
    Cdo2Message.TextBody = sBody
    Cdo2Message.HTMLBody = sHtmlBody
    
    ' Address the message.
    Cdo2Message.Sender = sSender
    Cdo2Message.From = sSender
    Cdo2Message.To = sTo
 
    ' Send the message.
    Cdo2Message.Send
    
    Set Cdo2Message = Nothing
    Set Cdo2Configuration = Nothing
    Set Cdo2Fields = Nothing

Open in new window

Avatar of c0ldfyr3
c0ldfyr3
Flag of Ireland image

Mate, you answered your own question. The application hasn't changed in 2 years and it's quite simple, so the cause of the slow down cannot be the code... I imagine the exchange server is slow maybe? Did you upgrade anything on your machine? MS Office maybe to 2007?
Avatar of jasonlassen
jasonlassen

ASKER

well, that's what i thought initially but when i checked it out, the exchange server's queues were nearly empty.  I understand and agree with you about the code not being the issue.  I cannot find anything that changed, nor does anyone with access recall changing anything.  obviously, *something* had to change though.  i've tried it on multiple workstations all with the same result so i'm convinced it is something on the exchange server or the LAN.  no clue where to start though.
Hey,

I just copy pasted your code into a new vb project, changed it to use late binding (CreateObject) and sent 11 messages in 2.9 seconds using my exchange server here so I don't know what to tell you apart from reboot the exchange server =P
what was the code that you used to use late binding?  I'm not that familiar with CDO.

PS exchange server has been rebooted a few times with no success.  hopefully late binding is the answer.
Instead of

Set Cdo2Configuration = New cdo.Configuration
Set Cdo2Message = New cdo.Message

Use

Set Cdo2Configuration = CreateObject("CDO.Configuration")
Set Cdo2Message = CreateObject("CDO.Message")

I don't think it will fix it though.
ah, i was thinking it was something else, sorry.  no, that didn't work.  are you using an exchange server within your firewall?  i'm thinking it is some setting on the exchange server.
i'm using an in-house exchange 2003 server, btw
ASKER CERTIFIED SOLUTION
Avatar of jasonlassen
jasonlassen

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