We help IT Professionals succeed at work.

Attempts to send email using classic ASP often times out

One of our customers has reported sporadic problems when our classic ASP application tries to send an email via CDOSYS to Exchange 2010 (running on Server 2008r2).

Occasionally, the 'SEND' happens immediately but it can sometimes take 30 seconds or more or even timeout ASP (90 seconds).

I use a test_mailer_components.asp page (from Pensaworks) and this exhibits the same problem - all quite random.

However, when run from the webserver (where problems above are happening) a VBS script that uses the same set of directives returns immediately, - every time.

Any ideas?
Watch Question

Big MontyWeb Ninja at large

have you checked out any of the IIS logs or event viewer for when the error occurs?

is the message being sent complex in it's creation?
Trevor HelpsTechnical Director


Yes - there's nothing showing up in the logs/eventvwr and the messages are always very simple.
Wayne BarronAuthor, Web Developer
Top Expert 2009

This does not correct the issue.
However, this will help to let you know when it has failed.
I am still learning the script, so there is still a lot that I do not know.

Run this, and see what happens.

myMail.To =  "email@address.net"
myMail.Subject = "Just another test email"
myMail.From = "master@domain.com"

myMail.HTMLBody = "Send something"
result = ""
On Error Resume Next
    result = myMail.Send()
    If Err.Number <> 0 Then result = result & ", error #" & Err.Number & ": " & Err.Description
On Error GoTo 0
If result = "" Then
   Response.Write "Mail sent out successfully"
   Response.Write "There was a Mail Server error.<br />We are sorry for any inconvenience."
   ' This is where you need to catch the issue, and then either
   ' 1 - Re-send out the failed emails
   ' 2 - Possible find some code to find a solution to the issue.
End IF


Open in new window

Big MontyWeb Ninja at large

Just just curious what app pool does the site run under? Is it the default one or a custom one?

If there are a lot of sites running on the server it may be worth creating iits own asp pool
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Can you post your code for both the ASP script and the VBS script.

Are you using cdoSendUsingPickup ?  I would also use authentication too.  But I think using the pickup directory will do the trick.

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Example CDO Message" 
objMessage.From = """Me"" <me@my.com>" 
objMessage.To = "test@paulsadowski.com" 
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60


'==End remote SMTP server configuration section==


Open in new window

Technical Director
Thank you all for your input.
We have got around the issued of delay to the Exchange server by using local SMTP server which then smarthosts to the Exchange server.  We now deal with localserver port 25 and this in turn puts the email into its mailroot\queue directory and it eventually gets delivered via the Exchange SMTP.  There's still a hold up at that stage but as far as our application is concerned it has delivered to the local SMTP and can move on.  This has done the trick for us and saves us having to fault find the real issue on the customers Exchange platform
Scott Fell - thanks for your input on the pickup directory.  Good to know we can get mail to the local SMTP server in this fashion also.

TB Team
Trevor HelpsTechnical Director


Accepting our own solution as a work around to the issue.