Email senden und abrufen

  • Sooo meine nächste Frage. :D

    Mein Script soll eine Email versenden und abrufen können.

    Und zwar soll das über meine Strato Emailadresse gehen.
    Posteingang (POP3) und Postausgangsserver (SMTP) sind gleich post.strato.de.

    Mir ist zu dem Thema die INet.au3 aufgefallen.

    Das senden wird wohl mit

    [autoit]


    #include <INet.au3>

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

    $s_SmtpServer = "mail.strato.de"
    $s_FromName = "My Name"
    $s_FromAddress = "From eMail Address"
    $s_ToAddress = "To eMail Address"
    $s_Subject = "My Test UDF"
    Dim $as_Body[2]
    $as_Body[0] = "Testing the new email udf"
    $as_Body[1] = "Second Line"
    $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
    $err = @error
    If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
    Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
    EndIf

    [/autoit]

    irgendwie gehen. Aber wo werden dort meine Zugangsdaten mitgesendet?

    Und wie kann ich prüfen, ob Emails auf meinem Email server liegen und gegebenenfalls runterladen und auslesen? Geht das überhaupt ohne ein Emailprog zu benutzen?

  • Zum Senden kenne ich die Variante "Func _INetSmtpMailCom" und da sind Variablen für Username und Passwort vorgesehen.

    Spoiler anzeigen
    [autoit]


    Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "")
    $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.Cc = $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])
    If FileExists($S_Files2Attach[$x]) Then
    $objEmail.AddAttachment ($S_Files2Attach[$x])
    Else
    $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
    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
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    ;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
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Sent the Message
    $objEmail.Send
    if @error then
    SetError(2)
    return $oMyRet[1]
    EndIf
    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]

    Oder siehe INetSendMail :)

    Einmal editiert, zuletzt von milko (14. April 2007 um 08:17)

  • Ich hab auch mal ein bisschen gesucht in der Hilfe und so, da steht aber nix weiter.


    Aber hier steht was dazu. Ich denke das könnte dir helfen


    Waluev

    Flensburg ist wie Payback - wenn man 18 Punkte hat bekommt man ein Fahrrad.

    Einmal editiert, zuletzt von Waluev (14. April 2007 um 08:29)