Recently I was working with a customer (at his Windows XP) where his CDO app (CDOSEND.vbs – given below) is failing to send email and throws the error “CDO_E_FAILED_TO_CONNECT” (you can refer the below given Output also). We tried setting CONFIG parameters like user name, SLL, password – but it doesn’t help.
Const cdoSendUsingPort = 2
If wscript.arguments.count <> 3 Then
wscript.echo "Arguments must be: <smtp server> <sender address> <recipient address>"
strSmartHost = trim(wscript.arguments(0))
strFrom = trim(wscript.arguments(1))
strTo = trim(wscript.arguments(2))
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' set the CDOSYS configuration fields to use port 25 on the SMTP server
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmartHost
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
' build HTML for message body
strHTML = "<HTML><BODY>" &_
"<b>This is the test HTML message body</b></br>" &_
' apply the settings to the message
Set .Configuration = iConf
.To = strTo
.From = StrFrom
.Subject = "This is a test CDO message (Sent via Port 25)"
.HTMLBody = strHTML
' cleanup of variables
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
1: CDO.Message.1 error '80040213'
3: The transport failed to connect to the server.
They were sending the mail using Port 25 and we made sure it’s not blocked by any AV solution. We tested sending mail using TELNET without any issues and collected NetMon logs for further analysis.
When we investigated further, we noticed that the specific machine had Outlook Express installed and a specific account profile was configured for it. We just deleted the profile entry from it.
Now we tried the above CDO app, it worked like a charm. Happy debugging!!