Problem bei der Ausführung eines Skripts

  • Hallo

    Ich habe ein Skritp geschrieben in welchem u.a. auch eine E-Mail versandt wird und zwar mit folgender Zeile

    $Body = "This is a test"
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)

    Die Parameter wurden vorher alle richtig definiert. Am Anfang des Skripts habe ich auch #include "C:\Programmieren\AutoIt\SMTP Mailer.au3".

    Wenn ich das Skript nun mit Run ausführe dann funktioniert alles wunderbar. Wenn ich das Skript aber mit Compile in eine exe umwandle dann funktioniert alles ausser die E-Mail wird nicht verschickt.

    Warum? Muss ich die SMTP Mailer.au3 auch noch compilieren?

    Einmal editiert, zuletzt von Helveticus (19. Mai 2010 um 20:45)

  • Hier das Skript

    Zuerst die SMTP Mailer.au3


    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.4.0
    Author: Jos (http://www.autoitscript.com/forum/index.php?showtopic=23860)
    Version: 1.0.0
    Date: 24.02.2010

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #include-once
    #Include<file.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

    [/autoit] [autoit][/autoit] [autoit]

    Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
    $objEmail.HTMLBody = $as_Body
    Else
    $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
    Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
    For $x = 1 To $S_Files2Attach[0]
    $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
    ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
    If FileExists($S_Files2Attach[$x]) Then
    $objEmail.AddAttachment ($S_Files2Attach[$x])
    Else
    ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
    SetError(1)
    Return 0
    EndIf
    Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
    Case "High"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
    Case "Normal"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
    Case "Low"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
    SetError(2)
    Return $oMyRet[1]
    EndIf
    $objEmail=""
    EndFunc ;==>_INetSmtpMailCom
    ;
    ;
    ; Com Error Handler
    Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
    EndFunc ;==>MyErrFunc

    [/autoit]


    Und jetzt mein Skript Test.au3


    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.4.0
    Author: xxx
    Version: 1.0.1
    Date: 24.02.2010

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #include "C:\Programmieren\AutoIt\SMTP Mailer.au3"

    [/autoit] [autoit][/autoit] [autoit]

    BlockInput(1)

    [/autoit] [autoit][/autoit] [autoit]

    $SmtpServer = "asmtp.mail.xxx.ch" ; address for the smtp-server to use - REQUIRED
    $FromName = "xxx" ; name from who the email was sent
    $FromAddress = "xxx@xxx.net" ; address from where the mail should come
    $ToAddress = "xxx@xxx.net" ; destination address of the email - REQUIRED
    $Subject = "Test" ; subject from the email - can be anything you want it to be
    $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail
    $AttachFiles = "" ; the file you want to attach- leave blank if not needed
    $CcAddress = "" ; address for cc - leave blank if not needed
    $BccAddress = "" ; address for bcc - leave blank if not needed
    $Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
    $Username = "xxx@xxx.net" ; username for the account used from where the mail gets sent - REQUIRED
    $Password = "xxx" ; password for the account used from where the mail gets sent - REQUIRED
    $IPPort = 25 ; port used for sending the mail
    $ssl = 1 ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;~ $IPPort=465 ; GMAIL port used for sending the mail
    ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

    [/autoit] [autoit][/autoit] [autoit]

    $Body = "Test"
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)

    [/autoit] [autoit][/autoit] [autoit]

    BlockInput(0)

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit]

    Einmal editiert, zuletzt von Helveticus (19. Mai 2010 um 11:44)

  • Vlt liegs daran das irgenteine Firewall die Complte EXE blockt

    Da muss ich Sprenger rechtgeben, das wäre auch das einzigste, wo ich mir vorstellen könnte... vorher habe ich an smtp authentifizierung (boar ich habs richtig geschrieben :thumbup: ) Aber uncompiled läufts ja...

    Einfach mal die Firewall ausschalten... Und was ich dir noch empfehlen möchte: Über dem Editor ist ein Button mit der Aufschrift SP und mit dem AutoIt logo. EInfach mal deinen Quelltext Makieren, dann einmal den AutoIt button drücken, danach einmal den SPButton drücken

    Kann ich hellsehen?

    Werd nicht frech Junger Mann :D

  • Vielen Dank.

    Ich habe die Windows-Firewall ausgeschaltet und es funktioniert immer noch nicht. Komischerweise funktioniert es auf einem anderen PC prima, dort habe ich die Kaspersky Firewall drauf und der wollte es blockieren, habe es aber erlaubt und dann hat es geklappt. Aber beim anderen PC habe ich ja auch die Windowos-Firewall deaktiviert.

    EDIT: Auf dem PC funktionieren Meldungen per SMTP von Avast und Acronis True Image super, bekomme eine E-Mail. Nur bei der Exe von AutoIt funktioniert es nicht.

    EDIT2: Ich habe die Exe jetzt auch noch auf einer virtual machine ausprobiert, auf dem ein sauberes originales XP Prof installiert ist und dort funktioniert es auch nicht, es muss also an AutoIt liegen. Auf dem PC, auf dem es funktioniert, ist AutoIt installiert, auf den anderen PCs nicht. Kann es daran liegen?

    Zitat

    Und was ich dir noch empfehlen möchte: Über dem Editor ist ein Button mit der Aufschrift SP und mit dem AutoIt logo. EInfach mal deinen Quelltext Makieren, dann einmal den AutoIt button drücken, danach einmal den SPButton drücken

    Wo finde ich diese Buttons?

    2 Mal editiert, zuletzt von Helveticus (19. Mai 2010 um 09:29)

  • Was @Jonathan meint ist der Editor hier in Forum wenn du auf Antworten gehst haste oben Buttons einer heisst SP ist für den Spioler Tag und wenn du danach den mit den Autoit logo drückst und dazwischen dein Quelltext packst sieht das viel besser aus. Siehe Beispiel:

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.4.0
    Author: myName
    Version: 1.0.0
    Date: theDate

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #include "C:\Programmieren\AutoIt\SMTP Mailer.au3"

    [/autoit] [autoit][/autoit] [autoit]

    BlockInput(1)

    [/autoit] [autoit][/autoit] [autoit]

    $SmtpServer = "asmtp.mail.xxx.ch" ; address for the smtp-server to use - REQUIRED
    $FromName = "Test" ; name from who the email was sent
    $FromAddress = "test@test.net" ; address from where the mail should come
    $ToAddress = "test@test.net" ; destination address of the email - REQUIRED
    $Subject = "Test" ; subject from the email - can be anything you want it to be
    $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail
    $AttachFiles = "" ; the file you want to attach- leave blank if not needed
    $CcAddress = "" ; address for cc - leave blank if not needed
    $BccAddress = "" ; address for bcc - leave blank if not needed
    $Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
    $Username = "test@test.net" ; username for the account used from where the mail gets sent - REQUIRED
    $Password = "test" ; password for the account used from where the mail gets sent - REQUIRED
    $IPPort = 25 ; port used for sending the mail
    $ssl = 1 ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;~ $IPPort=465 ; GMAIL port used for sending the mail
    ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

    [/autoit] [autoit][/autoit] [autoit]

    $Body = "Test"
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)

    [/autoit] [autoit][/autoit] [autoit]

    BlockInput(0)

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit]
  • Es muss irgendwie schon am PC liegen, da es auf einem PC ja funktioniert. Ich weiss nicht mehr weiter. Auf dem PC, wo es nicht funktioniert, habe ich die Windows-Firewall und den Avast Scanner, habe aber beide scho deaktiviert und es geht nicht. Das Skript führt er schon aus, aber irgendwie wird die ausgehende Verbindung blockiert. Bei dem PC, wo es funktioniert, habe ich Kaspersky drauf und dort fragt er nach, ob ich die Verbindung erlauben möchte.

  • Vielleicht weiss ja jemand wer es war. *hopefull*

    Oder vielleicht hat ja auch jemand Rat wegen meinem Problem. Ist voll strange, dass es auf dem PC nicht geht. An Avast kann es nicht liegen, habe das abgeklärt und ansonsten habe ich nichts installiert was einen Einfluss haben könnte. ;(

    EDIT: Da hatte wohl jemand das gleiche Problem.

    http://archiv.win-lite.de/index.php?page=Thread&threadID=13177

    Ich habe meine System nicht mit nLite entschlackt, ist alles original. Am IIS kann es auch nicht liegen, da auf dem PC, wo es funktioniert auch kein IIS installiert ist. Allerdings habe ich an den Diensten rumgespielt. Welche Dienste braucht es denn für SMTP?

    EDIT2: An den Diensten liegt es auch nicht, habe jetzt einmal alle Dienste aktiviert und es funktioniert auch nicht. Allerdings habe ich auf dem PC, auf dem es funktioniert Outlook installiert, auf den anderen PCs ist nur Outlook Express installiert allerdings ohne Konten. Könnte es sein, dass man zum Versenden über SMTP da noch was braucht?

    2 Mal editiert, zuletzt von Helveticus (19. Mai 2010 um 19:16)