Autoit-Script in Bart PE

  • Hallo,


    ich habe um ein schon existierendes Mails-Versandscript eine GUI gebastelt. Unter einem "richtigen" Windows kein Thema. Alles klappt super.

    Nun aber mein Problem.


    Sobald ich dieses Compilierte Script in Barts PE benutzen will, bringt er mit den Error-Code: 2 ohne weitere Meldung.


    Brauche ich denn besondere dll's oder änliches, damit die Autoit-Scripts unter Bart PE funktionieren?


    Spoiler anzeigen


    Lg Mel

    4 Mal editiert, zuletzt von Mellow (26. Juni 2009 um 17:05)

  • Ich würde behaupten, das AutoIt schon funktionieren wird. Nur das von der Funktion genutzte Objekt "CDO.Message" wird etwas benötigen, was unter BartPE nicht existiert.

    Wenn Du keinen Anhang verschicken willst, könntest Du "_INetSmtpMail()" der INet.au3 nutzen. Diese arbeitet direkt auf TCP-Ebene.

    Zur Nutzung dieses Forum's, ist ein Übersetzer für folgende Begriffe unerlässlich:

    "On-Bort, weier, verscheiden, schädliges, Butten steyling, näckstet, Parr, Porblem, scripe, Kompletenz, harken, manuel zu extramieren, geckukt, würglich, excell, acces oder Compilevorgeng"

  • Hallo,

    danke für den Tipp, nachdem ich die Authetifizierung noch mit eingebunden hatte lief es.

    LG

  • Hallo,

    nachdem das Script soweit seinen Dienst gemacht hatte, habe ich versucht das ganze unter Win7 zum laufen zu bekommen. Aber leider funktioniert das ganze da nicht so richtig mit dem Compilieren. Also habe ich meine alte WinXp-Kiste wieder flott gemacht, gepatched und das neue AutoIT installiert. Aber siehe da ich kann das Script nicht mehr richtig Compilieren. Es kommt immer wieder die Fehlermeldung:

    Code
    ERROR: _SmtpSend(): undefined function


    wie kann ich das Sctipt denn nun wieder zum laufen bekommen?


    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=ico\contact.ico
    #AutoIt3Wrapper_outfile=Mailer_v0002.exe
    #AutoIt3Wrapper_Res_Language=1031
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    ;##################################
    ; Include
    ;##################################
    #Include<file.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <INet.au3>
    #include <GuiConstants.au3>

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

    $Form1 = GUICreate("Hilfeformular", 518, 403, 257, 235)
    $in_name = GUICtrlCreateInput("", 80, 16, 129, 21)
    $in_vorname = GUICtrlCreateInput("", 80, 48, 129, 21)
    $in_telefon = GUICtrlCreateInput("", 360, 16, 129, 21)
    $in_sn = GUICtrlCreateInput("", 360, 48, 129, 21)
    $Edit1 = GUICtrlCreateEdit("", 18, 120, 473, 217)
    GUICtrlSetData(-1, "." )
    $Info = GUICtrlCreateButton("Info", 232, 24, 33, 33, $WS_GROUP)
    $btn_send = GUICtrlCreateButton("Senden", 88, 352, 105, 25, $WS_GROUP)
    $close = GUICtrlCreateButton("Fenster schließen", 320, 352, 97, 25, $WS_GROUP)
    $Label1 = GUICtrlCreateLabel("Telefon:", 304, 18, 43, 17)
    $Name = GUICtrlCreateLabel("Name:", 32, 18, 35, 17)
    $Vorname = GUICtrlCreateLabel("Vorname:", 18, 50, 49, 17)
    $Label2 = GUICtrlCreateLabel("nummer:", 276, 50, 74, 17)
    $Label3 = GUICtrlCreateLabel("Problembeschreibung", 18, 96, 106, 17)
    GUISetState(@SW_SHOW)

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

    while 1

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

    $nMsg = GUIGetMsg()
    Switch $nMsg

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

    Case $btn_send

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

    $s_SmtpServer = "***"
    $s_FromName = "***"
    $s_FromAddress = "***"
    $s_ToAddress = "***"
    $s_Subject = GUICtrlRead($in_sn) & ", " & GUICtrlRead($in_name) & ", " & "***"
    $s_UName = "****"
    $s_PWD = "***"

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

    Dim $as_Body[2]
    $as_Body[0] = "Name: " & GUICtrlRead($in_name) & @CRLF & "Vorname: " & GUICtrlRead($in_vorname) & @CRLF & "Telefon: " & GUICtrlRead($in_telefon) & @CRLF & "nummer: " & GUICtrlRead($in_sn) & @CRLF & @CRLF & "Text: "& @CRLF & GUICtrlRead($Edit1)

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

    $Response = _INetSmtpMailAuth ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_UName, $s_PWD, $s_Subject, $as_Body, "EHLO")
    $err = @error

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

    If $Response = 1 Then
    MsgBox(0, "Success!", "Ihre Mail wurde versandt.")
    Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
    EndIf
    Exit

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

    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $close
    Exit

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

    Case $Info
    MsgBox(0,"Information",".")

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

    EndSwitch
    WEnd

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

    Func _INetSmtpMailAuth($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Username, $s_Passwd, $s_Subject = "", $as_Body = "", $s_helo = "", $s_first="-1", $b_trace = 0)

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

    Local $v_Socket
    Local $s_IPAddress
    Local $i_Count
    Local $s_Send[9]
    Local $s_ReplyCode[9];Return code from SMTP server indicating success

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

    If $s_SmtpServer = "" Or $s_FromAddress = "" Or $s_ToAddress = "" Or $s_Username = "" Or $s_Passwd = "" Or $s_FromName = "" Or StringLen($s_FromName) > 256 Then
    SetError(1)
    Return 0
    EndIf

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

    If $s_helo = "" Then $s_helo = @ComputerName
    If TCPStartup() = 0 Then
    SetError(2)
    Return 0
    EndIf

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

    StringRegExp($s_SmtpServer, "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
    If @extended Then
    $s_IPAddress = $s_SmtpServer
    Else
    $s_IPAddress = TCPNameToIP($s_SmtpServer)
    EndIf
    If $s_IPAddress = "" Then
    TCPShutdown()
    SetError(3)
    Return 0
    EndIf
    $v_Socket = TCPConnect($s_IPAddress, 25)
    If $v_Socket = -1 Then
    TCPShutdown()
    SetError(4)
    Return (0)
    EndIf

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

    $s_Send[0] = "HELO " & $s_helo & @CRLF
    If StringLeft($s_helo,5) = "EHLO " Then $s_Send[0] = "EHLO " & $s_helo & @CRLF
    $s_ReplyCode[0] = "250"

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

    $s_Send[1] = "AUTH LOGIN" & @CRLF
    $s_ReplyCode[1] = "334"
    $s_Send[2] = _Base64Encoding($s_Username) & @CRLF
    $s_ReplyCode[2] = "334"
    $s_Send[3] = _Base64Encoding($s_Passwd) & @CRLF
    $s_ReplyCode[3] = "235"
    $s_Send[4] = "MAIL FROM: <" & $s_FromAddress & ">" & @CRLF
    $s_ReplyCode[4] = "250"
    $s_Send[5] = "RCPT TO: <" & $s_ToAddress & ">" & @CRLF
    $s_ReplyCode[5] = "250"
    $s_Send[6] = "DATA" & @CRLF
    $s_ReplyCode[6] = "354"

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

    $s_Send[7] = "From: " & $s_FromName & " <" & $s_FromAddress & ">" & @CRLF & _
    "To: " & "<" & $s_ToAddress & ">" & @CRLF & _
    "Subject: " & $s_Subject & @CRLF & _
    "Mime-Version: 1.0" & @CRLF & _
    "Content-Type: text/plain; charset=US-ASCII" & @CRLF & _
    @CRLF
    $s_ReplyCode[7] = ""

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

    $s_Send[8] = @CRLF & "." & @CRLF
    $s_ReplyCode[8] = "250"

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

    ; open stmp session
    If _SmtpSend($v_Socket, $s_Send[0], $s_ReplyCode[0], $b_trace, "220", $s_first) Then
    SetError(50)
    Return 0
    EndIf

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

    ; send header
    For $i_Count = 0 To UBound($s_Send) - 2
    If _SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then
    SetError(50 + $i_Count)
    Return 0
    EndIf
    Next

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

    ; send body records (a record can be multiline : take care of a subline beginning with a dot should be ..)
    For $i_Count = 0 To UBound($as_Body) - 1
    ; correct line beginning with a dot
    If StringLeft($as_Body[$i_Count], 1) = "." Then $as_Body[$i_Count] = "." & $as_Body[$i_Count]

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

    If _SmtpSend($v_Socket, $as_Body[$i_Count] & @CRLF, "", $b_trace) Then
    SetError(500 + $i_Count)
    Return 0
    EndIf
    Next

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

    ; close the smtp session
    $i_Count = UBound($s_Send) - 1
    If _SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then
    SetError(5000)
    Return 0
    EndIf

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

    TCPCloseSocket($v_Socket)
    TCPShutdown()
    Return 1
    EndFunc

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

    Func _Base64Encoding ($String)

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

    $strUmsetzung = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
    $strRetValue = ""

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

    For $i = 1 To StringLen($String) Step 3
    $strTok = StringMid($String,$i,3)
    Switch StringLen($strTok)
    Case 3
    $iTokVal = (Asc(StringMid($strTok,1,1)) * 256 + _
    Asc(StringMid($strTok,2,1))) * 256 + _
    Asc(StringMid($strTok,3,1))
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1)
    $iTokVal = BitShift($iTokVal,6)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1) & $strTokCryt
    $iTokVal = BitShift($iTokVal,6)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1) & $strTokCryt
    $iTokVal = BitShift($iTokVal,6)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1) & $strTokCryt
    $strRetValue &= $strTokCryt

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

    Case 2
    $iTokVal = (Asc(StringMid($strTok,1,1)) * 256 + _
    Asc(StringMid($strTok,2,1))) * 256
    $iTokVal = BitShift($iTokVal,6)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1)
    $iTokVal = BitShift($iTokVal,6)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1) & $strTokCryt
    $iTokVal = BitShift($iTokVal,6)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1) & $strTokCryt
    $strRetValue &= $strTokCryt & "="

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

    Case 1
    $iTokVal = Asc(StringMid($strTok,1,1)) * 65536
    $iTokVal = BitShift($iTokVal,12)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1)
    $iTokVal = BitShift($iTokVal,6)
    $strTokCryt = StringMid($strUmsetzung,(BitAND($iTokVal,63)) + 1,1) & $strTokCryt
    $strRetValue &= $strTokCryt & "=="

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

    EndSwitch
    Next

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

    Return $strRetValue
    EndFunc

    [/autoit]

    LG Mel

    p.s.: Ich muss gestehen, das ich ein klein wenig aus der Übung bin mit Autoit. :)