Custom CDO app throws error CDO_E_FAILED_TO_CONNECT

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.

Code Snippet:

 Option explicit
 Dim iMsg
 Dim iConf
 Dim Flds
 Dim strHTML
 Dim strSmartHost
 Dim strFrom
 Dim strTo
 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
  With Flds
  .Item("") = cdoSendUsingPort
  .Item("") = strSmartHost
  .Item("") = 10
  End With
  ' build HTML for message body
  strHTML = "<HTML><BODY>" &_
  "<b>This is the test HTML message body</b></br>" &_
  ' apply the settings to the message
  With iMsg
  Set .Configuration = iConf
  .To = strTo
  .From = StrFrom
  .Subject = "This is a test CDO message (Sent via Port 25)"
  .HTMLBody = strHTML
  End With
  ' cleanup of variables
  Set iMsg = Nothing
  Set iConf = Nothing
  Set Flds = Nothing
 End If


    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!!