Problem mit E-mail

  • Ich weiß das dieses Thema schon oft gibt aber bei meinem script kommt immer dieser fehler ; ### COM Error ! Number: 80020009 ScriptLine: 139 Description:Die Nachricht konnte nicht an den SMTP-Server gesendet werden. Der Transportfehlercode lautet 0x80040217. Die Serverantwort lautet not available


    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("#######", 501, 357, 192, 124)
    $Pic1 = GUICtrlCreatePic(@ScriptDir & "\########", 0, 0, 500, 356)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label1 = GUICtrlCreateLabel("########", 40, 24, 100, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("#########", 40, 64, 69, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("#########", 40, 104, 124, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("########", 40, 144, 198, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 256, 24, 225, 21)
    $Input2 = GUICtrlCreateInput("", 256, 64, 225, 21)
    $Input3 = GUICtrlCreateInput("", 256, 104, 225, 21)
    $Input4 = GUICtrlCreateInput("", 256, 144, 225, 21)
    $Button1 = GUICtrlCreateButton("Senden", 128, 200, 235, 65)
    GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
    $Progress1 = GUICtrlCreateProgress(8, 312, 478, 17)
    $Button2 = GUICtrlCreateButton("Credits", 400, 224, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

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

    ;##################################
    ; Variables
    ;##################################
    $SmtpServer = "smtp.web.de" ; address for the smtp-server to use - REQUIRED
    $FromName = "#############" ; name from who the email was sent
    $FromAddress = "##############" ; address from where the mail should come
    $ToAddress = "########" ; destination address of the email - REQUIRED
    $Subject = $Input1 ; subject from the email - can be anything you want it to be
    $Body = $Input2 ; 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 = "#######" ; username for the account used from where the mail gets sent - REQUIRED
    $Password = "######" ; password for the account used from where the mail gets sent - REQUIRED
    $IPPort = 25 ; port used for sending the mail normaly 25
    $ssl = 0 ; 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]

    ;##################################
    ; Script
    ;##################################
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
    EndIf

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

    ;============================================================================================================================================

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

    ;##################################
    ; Include
    ;##################################

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

    ;http://www.autoitscript.com/forum/index.ph…ndpost&p=166575
    ; The UDF
    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

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

    EndSwitch
    WEnd

    [/autoit]


    Villeicht kann mir jemand helfen und den fehler finden .


    MFG Nono

    Einmal editiert, zuletzt von Nono (10. Juni 2010 um 14:01)

  • Hallo nono,

    für web.de muss $IPPort = 587 gesetzt sein. Du scheinst aber auch noch einen groben Syntax-Fehler zu haben, denn dies (am Ende des Skriptes)

    [autoit]

    EndFunc

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

    EndSwitch
    WEnd

    [/autoit]

    darf in dieser Reihenfolge nicht vorkommen.
    Schau dir auch [gelöst] Daten an Email senden
    an. Im gleichen Thread in Post #14 sind weitere Informationen

    mfg (Auto)Bert

  • Danke erst mal , diesen link kenne ich schon und war da vorhin drauf. Könnstest du mir den script bitte einmal ohne fehler posten damit ich nur noch e-mail und so einsezten muss ?


    Das wer echt super nett :)

  • Hallo nono,

    so sollte es klappen, wenn du deine eigenen Angaben entsprechend anpasst:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>

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

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

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

    ;##################################
    ; Variables
    ;##################################
    $SmtpServer = "smtp.web.de" ; address for the smtp-server to use - REQUIRED
    $FromName = "nono" ; name from who the email was sent
    $FromAddress = "nono@web.de" ; address from where the mail should come
    $ToAddress = "########" ; destination address of the email - REQUIRED
    $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 = "nono@web.de" ; username for the account used from where the mail gets sent - REQUIRED
    $Password = "nonosPasswort" ; password for the account used from where the mail gets sent - REQUIRED
    $IPPort = 587 ; port used for sending the mail normaly 25
    $ssl = 0 ; 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][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("#######", 501, 357, 192, 124)
    $Pic1 = GUICtrlCreatePic(@ScriptDir & "\########", 0, 0, 500, 356)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label1 = GUICtrlCreateLabel("To Adress", 40, 24, 100, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Subject", 40, 64, 69, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Body", 40, 104, 124, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("########", 40, 144, 198, 24)
    GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 256, 24, 225, 21)
    $Input2 = GUICtrlCreateInput("", 256, 64, 225, 21)
    $Input3 = GUICtrlCreateInput("", 256, 104, 225, 21)
    $Input4 = GUICtrlCreateInput("", 256, 144, 225, 21)
    $Button1 = GUICtrlCreateButton("Senden", 128, 200, 235, 65)
    GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
    $Progress1 = GUICtrlCreateProgress(8, 312, 478, 17)
    $Button2 = GUICtrlCreateButton("Credits", 400, 224, 75, 25)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $ToAddress = GUICtrlRead($Input1) ; destination address of the email - REQUIRED <==========???????
    $Subject = GUICtrlRead($Input2) ; subject from the email - can be anything you want it to be
    $Body = GUICtrlRead($Input3) ; the messagebody from the mail - can be left blank but then you get a blank mail
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
    EndIf
    EndSwitch
    WEnd

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

    ;##################################
    ; Script
    ;##################################

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

    ;============================================================================================================================================

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

    ;##################################
    ; Include
    ;##################################

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

    ;http://www.autoitscript.com/forum/index.ph…ndpost&p=166575
    ; The UDF
    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] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]

    mfg (Auto)Bert

  • Hä , da kommt trotzdem server antwortet nicht habe alles richtig eingesetzt.

    Einmal editiert, zuletzt von Nono (18. Juni 2010 um 22:03)