_INetSmtpMail mit Passwort????

  • Hallo Leute,

    Wie mache ich das ein Passwort mit übergeben für den Mailversand?
    In der Autoit hilfe ist nix erklärt, ich bekomme immer Fehler 50 denke das es was mit dem Passwort von smtp zu tun hat.

    Spoiler anzeigen
    [autoit]


    $s_username = "blabla"
    $s_password = "lll"
    $s_SmtpServer = "192.168.222.254"
    $s_FromName = "administrator"
    $s_FromAddress = "administrator@zzz.net"
    $s_ToAddress = "xxx@xxx.de"
    $s_Subject = "TestMail vom Script"
    $as_Body[0] = "Hallo Das erstemal mit Mail"
    $as_Body[1] = "Zweite Zeile mal schauen"

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

    $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_username, $s_password)
    $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 micneu (11. August 2008 um 12:05)

    • Offizieller Beitrag

    Verwende einfach _INetSmtpMailCom() von Jos, damit gehts:

    _INetSmtpMailCom
    [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 = "",$IPPort=25, $ssl=0)
    $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])
    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") = $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
    ; Sent the Message
    $objEmail.Send
    if @error then
    SetError(2)
    return $oMyRet[1]
    EndIf
    EndFunc ;==>_INetSmtpMailCom

    [/autoit]
  • Hat Jemand dazu ein Beispiel ? Habe es bei mir eingefügt und bekomme keine Mail.

  • Hallo micneu.

    Hier mal ein Beispiel. CC und BCC funktionieren hier noch nicht, aber wenn das notwenig ist, dieses als Problem ins Forum stellen und Du bekommst Hilfe.

    Aber viel SPASS damit !!!

    Spoiler anzeigen
    [autoit]


    #include <inet.au3>
    #Include <file.au3>

    ;##################################
    ; Variables !!! Hier anpassen !!!
    ;##################################
    $s_SmtpServer = "***********" ; smtp vom sendeserver
    $s_FromName = "***********" ; der anmeldename
    $s_FromAddress = "***********" ; die angemeldete emailadresse
    $s_ToAddress = "***********" ; emailadresse an wen es gehen soll
    $s_Subject = "***********" ; das betreff

    $file = @SystemDir & "\info.txt" ; Datei die mitgesendet werden soll steht hier im gleichen Ordner via Script
    $fh = FileOpen($file, 0)
    $as_Body = FileRead($fh) ; text im body <-------------------- Inhalt der 5 Zeiligen Datei
    FileClose($fh)

    $s_AttachFiles = @SystemDir & "\info.txt" ; anhang <-------------------- @SystemDir & "\info.txt"
    $s_CcAddress = "" ; adresse für cc ; geht nicht !!!
    $s_BccAddress = "" ; aadresse für bcc ; geht nicht !!!
    $s_Username = "***********" ; username von dem gesendet werden soll
    $s_Password = "***********" ; passwort von dem sendekonto gebe ich eigentlich an ;)

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

    ; ggf. aktivieren, so es nicht einwandfrei arbeitet
    ; $IPPort=25 ; port - 25 oder 465 ; PORT 25 ist default
    ; $ssl=0 ; enables/disables ssl sonst 0 oder 1 ; 0 ist default

    ;##################################
    ; Script
    ;##################################
    Global $oMyRet[2]
    Global $oMyError = ObjEvent("Error", "ErrFunc")

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

    $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password);, $IPPort, $ssl)
    If @error then
    msgbox(0,"Error sending message","Error code:" & @error & " Description:" & $rc)
    EndIf
    #ce
    Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", _
    $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)
    $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])
    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") = $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
    ; 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] [autoit][/autoit] [autoit][/autoit]


    *) Erklärungen sind im Script

    Gruß, Crazy-A.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • @micneu.

    Lsg. durch Suchfunktion gefunden.
    Vllt. diese versuchen zu nutzen?

    Gruß, Crazy-A.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl