Daten an email senden

  • Hallo,

    ^^ ich und ein freund wollten mal etwas machen der code erstmal im spoiler ;) (ich weiss nicht ob es so ein beitrag schon gibt)

    Spoiler anzeigen


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    Opt("TrayMenuMode", 1)
    Opt("TrayMenuMode", 1)
    Opt("TrayMenuMode", 1)
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Newsletter empfangen", 308, 115, -1, -1)
    GUISetIcon("D:\008.ico")
    $ButtonOk = GUICtrlCreateButton("Newsletter empfangen", 70, 72, 131, 25, 0)
    $EnterPassLabel = GUICtrlCreateLabel("Um den Newsletter zu erhalten gib bitte deine Email an:", 8, 12, 264, 17)
    $email = GUICtrlCreateInput("em@il", 56, 40, 169, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    wir wollen das der Text (in dem fall die email) an unsere email weitergeleitet wird
    Betreff: Test
    Email: meine-email@web.de
    Text der in der mail steht: "der eingegebene text"

    wie geht das?^^

    3 Mal editiert, zuletzt von ThePierre (13. März 2010 um 22:39)

  • Spoiler anzeigen

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("TrayMenuMode", 1)
    Opt("TrayMenuMode", 1)
    Opt("TrayMenuMode", 1)
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Password Dialog", 251, 210, -1, -1)
    GUISetIcon("D:\008.ico")
    $Input1 = GUICtrlCreateInput("Input1", 56, 32, 97, 21)
    $Button1 = GUICtrlCreateButton("Button1", 48, 112, 81, 33, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $button1
    $s_SmtpServer = "web.de"
    $s_FromName = "Test"
    $s_FromAddress = "wustpierre123@web.de"
    $s_ToAddress = "alpha-09@web.de"
    $s_Subject = "Test"
    $s_Body = "Test"
    $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $s_Body)
    $err = @error
    If $Response = 1 Then
    MsgBox(0, "Erfolg!", "Die E-Mail wurde versandt")
    Else
    MsgBox(0, "Fehler!", "Das versenden der E-Mail schlug fehl. Fehlercode: " & $err)
    EndIf

    EndSwitch
    WEnd


    ich will das $input1 (der text) an die meila gesendet wird ? wie mache ich dies?
    dieser code so wie er ist richtig?

  • jetzt sagt er das versenden schlug fehl, Code 4
    8| ?
    Hilfe!
    jetztige code:

    Spoiler anzeigen

    #include <INet.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("TrayMenuMode", 1)
    Opt("TrayMenuMode", 1)
    Opt("TrayMenuMode", 1)
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Password Dialog", 251, 210, -1, -1)
    GUISetIcon("D:\008.ico")
    $Input1 = GUICtrlCreateInput("Input1", 56, 32, 97, 21)
    $Button1 = GUICtrlCreateButton("Button1", 48, 112, 81, 33, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $button1
    $s_SmtpServer = "web.de"
    $s_FromName = "hack"
    $s_FromAddress = "wustpierre123@web.de"
    $s_ToAddress = "alpha-09@web.de"
    $s_Subject = "$input1"
    $s_Body = "$input1"
    $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $s_Body)
    $err = @error
    If $Response = 1 Then
    MsgBox(0, "Erfolg!", "Die E-Mail wurde versandt")
    Else
    MsgBox(0, "Fehler!", "Das versenden der E-Mail schlug fehl. Fehlercode: " & $err)
    EndIf

    EndSwitch
    WEnd

    Einmal editiert, zuletzt von ThePierre (13. März 2010 um 17:06)

  • Hallo ThePierre,

    für GMX-Konten funktioniert dieses Skript:

    Spoiler anzeigen
    [autoit]

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

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

    #include <_INetSmtpMailCom.au3>

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

    ;##################################
    ; Variables
    ;##################################
    $SmtpServer = "mail.gmx.net" ; address for the smtp-server to use - REQUIRED
    $FromName = "My Name" ; name from who the email was sent
    $FromAddress = "anybody.@gmx.de" ; address from where the mail should come
    $ToAddress = "everybody.@gmx.de" ; destination address of the email - REQUIRED
    $Subject = "Userinfo" ; subject from the email - can be anything you want it to be
    $Body = "Test" ; 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 = "anybody@gmx.de" ; 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]

    zusammen mit dieser UDF (_INetSmtpMailCom.au3):

    Spoiler anzeigen
    [autoit]

    ;##################################
    ; Include
    ;##################################
    #Include<file.au3>
    ;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]

    mfg (Auto)Bert

  • Genau, und dann in deinem eigenen Scipt diese Funktion anstelle der normalen aufrufen...

    Spoiler anzeigen

    Grundkenntnisse in: C++, JavaScript
    Sehr gute Kenntnisse: PHP, JAVA, C und näturlich AutoIt


    Klaviatur, Anhang UDF, GDI+ Mühle

    Zitat

    "Wenn einen um 20h der Pizzadienst anruft und fragt, ob man's nur vergessen hat und ob man das gleiche
    möchte wie immer -- dann sollte man sein Bestellverhalten evtl überdenken"

  • ich habe das Skript aus Post #11 jetzt auch mit Web.de und HotMail.de getestet.

    Web.de:

    • $SmtpServer = "smtp.web.de" ; address for the smtp-server to use - 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

    HotMail:

    • $SmtpServer = "smtp.live.com" ; address for the smtp-server to use - REQUIRED
    • $IPPort = 25 ; port used for sending the mail normaly 25
    • $ssl = 1 ; enables/disables secure socket layer sending - put to 1 if using httpS

    Google:

    • $SmtpServer = "smtp.googlemail.com" ; address for the smtp-server to use - REQUIRED
    • $IPPort = 465 ; port used for sending the mail normaly 25
    • $ssl = 1 ; enables/disables secure socket layer sending - put to 1 if using httpS

    mfg (Auto)Bert

    2 Mal editiert, zuletzt von autoBert (19. Februar 2012 um 23:53) aus folgendem Grund: Mailprovider nachgetragen

  • habe aber noch ne frage^^ (soll ich neues thread machen oder dieses?) gehört nicht zu dem thema :rolleyes:

  • Hallo,

    ich nutze auch die UDF und wollte die mal ein bisschen aufräumen und Tidy machen. Und die Präfixe der Variablen nach meinem Standard angleichen.
    Wozu ist denn $i_Error da?

  • Sofern die UDF da oben vollständig ist sehe ich keine Verwendung der beiden $i_error_* Variablen. Vielleicht hatten die ja mal in einer früheren Version der UDF eine Funktion und wurden vergessen...