"CDO.Message.1: The transport failed to connect to the
server."
'Sending a text email using a remote server
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Test"
objMessage.Sender = "Exchange Account Mail Adresse"
objMessage.To = "somebodys mail adresse"
objMessage.TextBody = "Test!"
'==This section provides the configuration information
for the remote SMTP server.
'==Normally you will only change the server name or IP.
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/smtpserve
r") = "127.0.0.1"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserve
rport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Habe den Exchange Server nicht selbst aufgesetzt.
Gibt es irgendwas, was ich prüfen kann?Oder ist das
Skript falsch?
Danke für Eure Hilfe!
mfg
Robert B.
objMessage.Configuration.Fields.Update
objMessage.Send
Danke für Eure Hilfe!
mfg
Robert B.
Hallo Robert!
Probiere mal untenstehnde Funktion.
Die Kommentare sollten für's Verständnis des Ablaufs, der Parameter
ausreichen. Dieses Script habe ich mal mit detailierten Infos von
http://msdn.microsoft.com oder der MSDN erstellt.
Viel Erfolg beim Versenden von Mails ;-))
Teddy
P.S. Der WSH ist bei mir immer so konfiguriert, dass alle
WScript.Echo-Ausgaben auf der Kommandozeile erfolgen (CScript
//H:CScript --> Changes the default script host to CScript.exe). Kommt
besser als ständig <Return> zu drücken, um die Informationen über den
Scriptverlauf 'wegzudrücken. Besonders wenn das Script nachts läuft und
niemand Lust hat, <Return> zu drücken ;-)
-----------------------------
'// <method name="S:SendMail>
'// <summery>sendet eine Mail via SMTP </summery>
'// <remarks>
'// The intSendUsing field defaults to cdoSendUsingPickup if there is a
local SMTP
'// service available on the computer
'// 1 - Verwendung des lokalen SMTP service pickup directorys
'// 2 - Verwendung des Netzwerks (SMTP over the network)
'// 3 - Verwendung des Exchange Mail Submission Uniform Resource Identifier
(URI)
'// </remarks>
'// <param name="strFrom" example="sen...@mail.mynet.net"
type="ByVal">e-Mail-Adresse des Senders</param>
'// <param name="strTo" example="p...@mail.mynet.net"
type="ByVal">e-Mail-Adresse des Absenders</param>
'// <param name="strSubject" example="Dies ist ein Beispiel"
type="ByVal">Betreff der Mail</param>
'// <param name="strBody" example="Hier der Text!" type="ByVal">Text der
Mail</param>
'// <param name="strSMTPServer" example="ruebensahm" type="ByVal">Name des
SMTP Servers</param>
'// <param name="intPort" example="123" type="ByVal">Port 25 Standard
(s.u.)</param>
'// <param name="intSendUsing" example="" type="ByVal">1=sonstwo; 2 = lokal
(SMTP ist auf dem lokalen Computer installiert)</param>
'// <returns>True, wenn erfolgreich versendet; sonst False</returns>
'// <code>Function SendMail(ByVal strFrom, ByVal strTo, ByVal strSubject,
ByVal strBody,ByVal strSMTPServer, ByVal intPort, ByVal intSendUsing)</code>
'// <author version="1.0.0" date="01.04.03">Teddy Sohnrey/Frankfurt</author>
'// </method>
' --------------------------------------------------------------------------
-------------------------------------
Function SendMail(ByVal strFrom, ByVal strTo, ByVal strSubject, ByVal
strBody, _
ByVal strSMTPServer, ByVal intPort, ByVal intSendUsing)
' -------------------------------------
' --------------------------------------------------------------------------
-------------------------------------
Dim objEmail
SendMail = False
Set objEmail = CreateObject("CDO.Message")
If Err Then
ShowErrorMessage
Exit Function
Else
WScript.Echo("creating e-mail ..." + vbCRLF )
End If
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSubject
objEmail.Textbody = strBody
WScript.Echo(Space(3) + "From: " & strFrom)
WScript.Echo(Space(3) + "To: " & strTo)
WScript.Echo(Space(3) + "Subject: " & strSubject)
If Len(strBody) > 35 Then
WScript.Echo(Space(3) + "Body: " & Left(strBody, 35) + " ...")
Else
WScript.Echo(Space(3) + "Body: " & strBody)
End If
If g_strFileName <> "" Then WScript.Echo(Space(3) + "Input file: " &
g_strFileName)
WScript.Echo(Space(3) + "SMTP Server: " & strSMTPServer)
WScript.Echo(Space(3) + "Port: " & intPort & vbCRLF)
' -> Now specify the configuration properties for the remote SMTP server.
' the next property is set to 2, meaning that the SMTP service is not
installed on this computer.
' Messages must instead be sent by using the computer specified in the
SMTPServer Property
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusing") = intSendUsing
' the next property is set to the parameter strSMTPServer which represents
your SMTP server
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserver") = strSMTPServer
' the next property is set to 25, the default SMTP port for most computers.
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserverport") = intPort
objEmail.Configuration.Fields.Update
objEmail.Send
If Err Then ' check for errors
ShowErrorMessage
Exit Function
Else
WScript.Echo("Send mail successfully to '" & strTo & "'" + vbCRLF )
SendMail = True
End If
Set objEmail = Nothing
End Function
-----------------------------
probiers mal mit unten eingefügtem, gelöschten Code
> Ich bekomme bei untem angegebenen Skript, das ich direkt
> am Exchange Server ausführe (Port 25) folgenden Fehler:
>
> "CDO.Message.1: The transport failed to connect to the
> server."
>
> 'Sending a text email using a remote server
>
> Set objMessage = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
> objMessage.Subject = "Test"
> objMessage.Sender = "Exchange Account Mail Adresse"
> objMessage.To = "somebodys mail adresse"
> objMessage.TextBody = "Test!"
>
>
>
> objMessage.Send
>
> Habe den Exchange Server nicht selbst aufgesetzt.
> Gibt es irgendwas, was ich prüfen kann?Oder ist das
> Skript falsch?
>
> Danke für Eure Hilfe!
HTH Jürgen