title: CDO.message vbscript - transport failed to connect
body: <p>I have a vbscript on a Windows 7 machine in a branch office.  It works just fine.  I copied the code to a second branch office Windows 7 machine and I get an error. I'm out of ideas.</p>
  
  <p>Both Windows machines have MS Outlook installed. </p>
  
  <pre><code> Do While asObj.ConnectionState = asCONN_CONNECTED
          WeekDayNumber = Weekday(Now())
          HourNumber = Hour(Now())
          'WScript.Echo asObj.HasData
          If asObj.HasData Then
          WScript.Echo asObj.ReceiveString
              WriteData asObj.ReceiveString
              uploadData
              CycleDate = Now()
              asObj.Sleep 300
          Else
              If WeekDayNumber &gt; 1 And WeekDayNumber &lt; 7 And HourNumber &gt; 8 And HourNumber &lt; 17 Then
                  DiffInMinutes = DateDiff("n",CycleDate,Now())
                  'WScript.Echo "Day=" &amp; WeekDayNumber &amp; vbCrLf &amp; "Hour=" &amp; HourNumber &amp; vbCrLf &amp; "cycle=" &amp; CycleDate &amp; vbCrLf &amp; "diff=" &amp; DiffInMinutes &amp; vbCrLf &amp; " Now=" &amp; Now()
                  If DiffInMinutes &gt; 2 Then
                      SendAlertEmail
                      WriteData "Alert email sent  " &amp; Now() &amp; vbCrLf
                      WScript.Echo cyclecounter &amp; " no data"
                      CycleDate = Now()
                      ' Sleep 5 minutes
                      asObj.Sleep 1000
                  End If
              End If
         End If
      Loop
  ' And finally, disconnect
      WScript.Echo "Disconnect -- we should never get to this point. Call Chris!"
      asObj.Disconnect
  Else
      WScript.Echo "bad connection. You have to restart the script"
  End If
  
      Sub WriteData(sData)
          Const ForAppending = 8
          Const OutputFile = "d:\calldata\calldata_data\CallData_$DATE$mtp.txt"
  
          Dim DateNow
          Dim varDate
          Dim objFile
          Dim objFSO
  
          ' WScript.Echo sData
  
          Datenow = Date()
          varDate = Year(DateNow) &amp; Right("0" &amp; Month(DateNow), 2) &amp; Right("0" &amp; Day(DateNow), 2)
  
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          Set objFile = objFSO.OpenTextFile(Replace(OutputFile, "$DATE$", varDate), ForAppending, True)
          objFile.WriteLine sData
          objFile.Close
  
          Set objFile = Nothing
          Set objFSO = Nothing
      End Sub
  
  Sub uploadData
  
  Dim objShell
  Set objShell = Wscript.CreateObject("WScript.Shell")
  
  objShell.Run "c:\calldata\FTPupload.vbs",10,True 
  objShell.Run "c:\calldata\updateCallData.vbs",10,True
  ' Using Set is mandatory
  Set objShell = Nothing
  
  End Sub
  Sub SendAlertEmail
  
  Set email = CreateObject("CDO.Message")
  WScript.Echo "step 1"
  
  email.Subject = "MTP - Possible phone time collection failure"
  email.From = "x@gmail.com"
  email.To = "x@x.com;x@x.com;x@x.com"
  email.TextBody = Now() &amp; "  The collection of phone time that is done on the MTP Domain Controller seems to have failed. There has been no data for quite a while."
  
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication  
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "x@gmail.com"
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
  
  
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com"
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
  
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
  email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30 
  
  email.Configuration.Fields.Update
  email.Send
  If Err Then
           WScript.Echo "SendMail Failed:" &amp; Err.Description
      End If
  set email = Nothing
  'WScript.Echo"step 2"
  End Sub
  </code></pre>