Email senden ohne irgentein Fenster?

  • Hallo, ich möchte ein script schreiben, dass eine Email sendet:
    ungefähr so:


    [autoit]

    $empfaenger = "xyz@domain.de"
    $absender = "xyz2@domain.de"
    $title = "Test email"
    $text = "hallo, ich bin ein beispiel"

    email.Send($empfaenger,$absender,$title,$text)

    [/autoit]


    Ich habe hier auch was mit emails gefunden, aber das hat nicht funktioniert
    So sollte das die email vill. absenden oder so ähnlich.
    Weiß jemand wie das geht und ob das geht und könnte der mir helfen?

    Lg
    Robin

  • habs zwar bisher noch nicht gebraucht, aber laut Hilfe dürfte "_INetSmtpMail " gehen

  • Ok, aber was ist SmptServer?
    Ich hab schon verschiedene Sachen ausprobiert aber die funktionieren alle nicht.
    Da kommt immer ein error:

    [autoit]

    #include <INet.au3>

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

    $s_SmtpServer = "192.168.1.1"
    $s_FromName = "My Name"
    $s_FromAddress = "test@example.com"
    $s_ToAddress = "test@example.com"
    $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]

    Einmal editiert, zuletzt von INFACT (25. März 2011 um 21:54)

    • Offizieller Beitrag

    Smtpserver ist dein Mailserver .Bei Arcor ist das z.B. mail.arcor.de

  • web wäre smpt.web.de
    schau einfach auf der betreffenden seite in den einstellungen
    da steht des immer

    Padmak

  • Ich find die Funktion hier am besten ( besonders weil sie als einzige bei mir geht^^ )
    Hat kein Fenster oder so, ist einfach super =)

    Spoiler anzeigen
    [autoit]

    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    $rc = _INetSmtpMailCom($mail_server,$absender_name,$absender_adresse, $empfaenger_adresse, $betreff, $nachrichtentext, $anhang, $cc_emfaenger,$bcc_empfaenger, $mail_benutzername, $mail_passwort)
    If @error then
    msgbox(0,"Error sending message","Error code:" & @error & " Description:" & $rc)
    EndIf

    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 $ex = 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]
  • probier's mal mit meiner angepassten Variante:
    http://www.autoit.de/index.php?page=Thread&threadID=11263

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)