|
You last visited: Today at 04:18
Advertisement
_INetSmtpMail Probelm
Discussion on _INetSmtpMail Probelm within the AutoIt forum part of the Coders Den category.
09/09/2010, 17:37
|
#1
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
_INetSmtpMail Probelm
Hallo,
es sieht bei mir so aus:
PHP Code:
#include <INet.au3> $s_SmtpServer = "mail.gmx.net" $s_FromName = "Jonas" $s_FromAddress = "****@gmx.de" $s_ToAddress = "****@hotmail.de" $s_Subject = "My Test UDF" $s_UName = "****@gmx.de" $s_PWD = "mein pw um mich einzuloggen" #cs $arIniRead = IniReadSection(@ScriptDir & '\mails.ini', "mail") $s_SmtpServer = $arIniRead[1][1] $s_FromName = $arIniRead[2][1] $s_FromAddress = $arIniRead[3][1] $s_ToAddress = $arIniRead[4][1] $s_Subject = $arIniRead[5][1] $s_UName = $arIniRead[6][1] $s_PWD = $arIniRead[7][1] MsgBox(0, "", $s_SmtpServer & ' ' & $s_FromName & ' ' & $s_FromAddress & ' ' & $s_ToAddress & ' ' & $s_Subject & ' ' & $s_UName & ' ' & $s_PWD) #ce Dim $as_Body[2] $as_Body[0] = "Testing the new email udf" $as_Body[1] = "Second Line" $Response = _INetSmtpMailAuth($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_UName, $s_PWD, $s_Subject, $as_Body) ;~ $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 ;=============================================================================== ; ; Function Name: _INetSmtpMailAuth() ; Description: Sends an email using SMTP over TCP IP. ; Parameter(s): $s_SmtpServer - SMTP server to be used for sending email ; $s_FromName - Name of sender ; $s_FromAddress - eMail address of sender ; $s_ToAddress - Address that email is to be sent to ; $s_Username - Username for Authentication (bernd670) ; $s_Passwd - Password for Authentication (bernd670) ; $s_Subject - Subject of eMail ; $as_Body - Single dimension array containing the body of eMail as strings ; $s_helo - Helo identifier (default @COMPUTERNAME) sometime needed by smtp server ; $s_first - send before Helo identifier (default @CRLF) sometime needed by smtp server ; $b_trace - trace on a splash window (default 0 = no trace) ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - 0 and sets ; @ERROR = 1 - Invalid Parameters ; @ERROR = 2 - Unable to start TCP ; @ERROR = 3 - Unable to resolve IP ; @ERROR = 4 - Unable to create socket ; @ERROR = 5x - Cannot open SMTP session ; @ERROR = 50x - Cannot send body ; @ERROR = 5000 - Cannot close SMTP session ; Authors: Original function to send email via TCP - Asimzameer ; Conversion to UDF - Walkabout ; Correction Helo, timeout, trace - Jpm ; Correction send before Helo - Jpm ; Include Authentication - bernd670 ; ;=============================================================================== Func _INetSmtpMailAuth($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Username, $s_Passwd, $s_Subject = "", $as_Body = "", $s_helo = "", $s_first = "-1", $b_trace = 0) Local $v_Socket Local $s_IPAddress Local $i_Count Local $s_Send[9] Local $s_ReplyCode[9];Return code from SMTP server indicating success If $s_SmtpServer = "" Or $s_FromAddress = "" Or $s_ToAddress = "" Or $s_Username = "" Or $s_Passwd = "" Or $s_FromName = "" Or StringLen($s_FromName) > 256 Then SetError(1) Return 0 EndIf If $s_helo = "" Then $s_helo = @ComputerName If TCPStartup() = 0 Then SetError(2) Return 0 EndIf StringRegExp($s_SmtpServer, "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)") If @extended Then $s_IPAddress = $s_SmtpServer Else $s_IPAddress = TCPNameToIP($s_SmtpServer) EndIf If $s_IPAddress = "" Then TCPShutdown() SetError(3) Return 0 EndIf $v_Socket = TCPConnect($s_IPAddress, 25) If $v_Socket = -1 Then TCPShutdown() SetError(4) Return (0) EndIf $s_Send[0] = "EHLO " & $s_helo & @CRLF ;~ If StringLeft($s_helo,5) <> "EHLO " Then $s_Send[0] = "EHLO " & $s_helo & @CRLF $s_ReplyCode[0] = "250" $s_Send[1] = "AUTH LOGIN" & @CRLF $s_ReplyCode[1] = "334" $s_Send[2] = _Base64Encoding($s_Username) & @CRLF $s_ReplyCode[2] = "334" $s_Send[3] = _Base64Encoding($s_Passwd) & @CRLF $s_ReplyCode[3] = "235" $s_Send[4] = "MAIL FROM: <" & $s_FromAddress & ">" & @CRLF $s_ReplyCode[4] = "250" $s_Send[5] = "RCPT TO: <" & $s_ToAddress & ">" & @CRLF $s_ReplyCode[5] = "250" $s_Send[6] = "DATA" & @CRLF $s_ReplyCode[6] = "354" $s_Send[7] = "From: " & $s_FromName & " <" & $s_FromAddress & ">" & @CRLF & _ "To: " & "<" & $s_ToAddress & ">" & @CRLF & _ "Subject: " & $s_Subject & @CRLF & _ "Mime-Version: 1.0" & @CRLF & _ "Content-Type: text/plain; charset=US-ASCII" & @CRLF & _ @CRLF $s_ReplyCode[7] = "" $s_Send[8] = @CRLF & "." & @CRLF $s_ReplyCode[8] = "250" ; open stmp session If _SmtpSend($v_Socket, $s_Send[0], $s_ReplyCode[0], $b_trace, "220", $s_first) Then SetError(50) Return 0 EndIf ; send header For $i_Count = 0 To UBound($s_Send) - 2 If _SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then SetError(50 + $i_Count) Return 0 EndIf Next ; send body records (a record can be multiline : take care of a subline beginning with a dot should be ..) For $i_Count = 0 To UBound($as_Body) - 1 ; correct line beginning with a dot If StringLeft($as_Body[$i_Count], 1) = "." Then $as_Body[$i_Count] = "." & $as_Body[$i_Count] If _SmtpSend($v_Socket, $as_Body[$i_Count] & @CRLF, "", $b_trace) Then SetError(500 + $i_Count) Return 0 EndIf Next ; close the smtp session $i_Count = UBound($s_Send) - 1 If _SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then SetError(5000) Return 0 EndIf TCPCloseSocket($v_Socket) TCPShutdown() Return 1 EndFunc ;==>_INetSmtpMailAuth ;=============================================================================== ; ; Function Name: _Base64Encoding() ; Description: Kodiert eine Zeichenfolge mit dem Base64-Verfahren ; (http://de.wikipedia.org/wiki/Base64) ; Parameter(s): $String - Zeichenfolge die kodiert werden soll ; Requirement(s): None ; Return Value(s): Kodierte Zeichenfolge ; Authors: bernd670 ; ;=============================================================================== Func _Base64Encoding($String) $strUmsetzung = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" $strRetValue = "" For $i = 1 To StringLen($String) Step 3 $strTok = StringMid($String, $i, 3) Switch StringLen($strTok) Case 3 $iTokVal = (Asc(StringMid($strTok, 1, 1)) * 256 + _ Asc(StringMid($strTok, 2, 1))) * 256 + _ Asc(StringMid($strTok, 3, 1)) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) $iTokVal = BitShift($iTokVal, 6) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt $iTokVal = BitShift($iTokVal, 6) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt $iTokVal = BitShift($iTokVal, 6) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt $strRetValue &= $strTokCryt Case 2 $iTokVal = (Asc(StringMid($strTok, 1, 1)) * 256 + _ Asc(StringMid($strTok, 2, 1))) * 256 $iTokVal = BitShift($iTokVal, 6) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) $iTokVal = BitShift($iTokVal, 6) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt $iTokVal = BitShift($iTokVal, 6) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt $strRetValue &= $strTokCryt & "=" Case 1 $iTokVal = Asc(StringMid($strTok, 1, 1)) * 65536 $iTokVal = BitShift($iTokVal, 12) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) $iTokVal = BitShift($iTokVal, 6) $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt $strRetValue &= $strTokCryt & "==" EndSwitch Next Return $strRetValue EndFunc ;==>_Base64Encoding
Doch dann kommt immer: Error: Unknown function name
Kann mir jmd. helfen?
Ich würde hier gerne nur hilfreiche beiträge sehen und kein spam^^
bin am verzweifeln egal was ich ändere immer nen error <.<
|
|
|
09/09/2010, 17:51
|
#2
|
elite*gold: 116
Join Date: Oct 2007
Posts: 677
Received Thanks: 248
|
Ja wenn es keine _SmtpSend Function gibt, kannst du logischerweise auch keine funktion mit dem namen aufrufen.
Steht doch alles im Scite Editor unten im Log wenn man mal hinguckt.
|
|
|
09/09/2010, 17:53
|
#3
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
Sry bin grad verwirrt, wie sieht so eine funktion aus nd wo muss die hin?
sry weiß grad nich was los is o.o
|
|
|
09/09/2010, 17:57
|
#4
|
elite*gold: 116
Join Date: Oct 2007
Posts: 677
Received Thanks: 248
|
Super, wenn du deinen kompletten Code einfach nur von iwo kopierst bringt das auch nix.
Versuch's doch mal selber anstatt immer gleich zu leechen, so lernt man doch nie was.
|
|
|
09/09/2010, 18:00
|
#5
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
ja ich möchte doch nen ganzen code haben, damit ich daran arbeiten kann und selbst rausbekomme wofür was ist
und ich finde ja auch kein how to bzw tutorial dazu ...
|
|
|
09/09/2010, 18:26
|
#6
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
Quote:
Originally Posted by B-O
Sry bin grad verwirrt, wie sieht so eine funktion aus nd wo muss die hin?
sry weiß grad nich was los is o.o
|
Wenn du noch nichtmal weißt was eine funktion ist, dann schau dir am besten nochmal ein par tutorials mit den urschleim an
|
|
|
09/09/2010, 18:29
|
#7
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
Was eine funktion ist weiß ich doch^^
ich suche eig nur nen tut wo das mit der _INetSmtpMail beschrieben ist, oder das mir jmd. das erklärt...
aber naja muss ich iwie wohl selbst hinbekommen
|
|
|
09/09/2010, 18:50
|
#8
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
Hab mich mit emails senden bisher noch nicht weiter beschäftigt.
Aber hier ein par ergebnisse nach kurzen googeln.
|
|
|
09/09/2010, 18:57
|
#9
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
erstmal danke.
beim ersten link kommt kein error und keine msg box, ist das normal so? mh ich gucke mal..
bzw wie bekomm ich ein gui das den text ausliest und mithilfe dieses codes
Quote:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.12.1
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
;
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
; Variables
;##################################
$SmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED
$FromName = "Name" ; name from who the email was sent
$FromAddress = "" ; address from where the mail should come
$ToAddress = "" ; destination address of the email - REQUIRED
$Subject = "Userinfo" ; subject from the email - can be anything you want it to be
$Body = "" ; 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
$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
;##################################
; Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$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
;
; 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
|
hin?
|
|
|
09/09/2010, 19:24
|
#10
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
Welcher Text soll denn ausgelesen werden?
Hast du in Zeile 20-33 die für dich zutreffenden Daten eingegeben?
|
|
|
09/09/2010, 20:16
|
#11
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
So ich hab was anderes gefunden wmit es geht, nun hab ich noch eine Frage dann stör ich nicht mehr^^
So ich hab jetzt einen script der funktioniert, ich habe auch ein gui dazu gemacht nun weiß ich nicht wie autoit die 2 inputboxen auslesen kann
Code
Quote:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: XXlolimanxx
Script Function:
Liest den Text aus einer Editbox einer Gui aus und sendet es per E-Mail
#ce ----------------------------------------------------------------------------
Global $SmtpServer , $FromName , $FromAddress , $ToAddress , $Subject , $ssl , $oMyRet , $HexNumber , $oMyError
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 358, 278, 232, 156)
$Label1 = GUICtrlCreateLabel("Test", 24, 8, 313, 35)
GUICtrlSetFont(-1, 20, 400, 0, "Make Juice")
$Label2 = GUICtrlCreateLabel("test", 16, 56, 17, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("test", 16, 88, 22, 17)
GUICtrlCreateInput("", 48, 56, 97, 21)
GUICtrlCreateInput("", 48, 96, 97, 21)
$Exp = GUICtrlCreateLabel("test", 16, 152, 31, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$HP = GUICtrlCreateLabel("test", 16, 184, 26, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$MP = GUICtrlCreateLabel("test", 16, 216, 27, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 56, 152, 17, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 56, 184, 17, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 56, 216, 17, 17)
$DMG = GUICtrlCreateLabel("test", 184, 152, 42, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 248, 152, 17, 17)
$Button1 = GUICtrlCreateButton("test", 200, 208, 137, 49, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func _Senden ()
ProgressOn ("Test","Test E-Mail wird versendet! Bitte warten!","Einstellungen auslesen.",-1,-1,2)
$Bericht = GUICtrlRead ($Edit1)
;
;##################################
; Include
;##################################
;##################################
; Variables
;##################################
$SmtpServer = "mail.gmx.net" ; address for the smtp-server to use - REQUIRED
$FromName = "jonas" ; name from who the email was sent
$FromAddress = "[email protected]" ; address from where the mail should come
$ToAddress = "[email protected]" ; destination address of the email - REQUIRED
$Subject = "test" ; subject from the email - can be anything you want it to be
$Body = $Bericht ; 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 = "[email protected]" ; 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
$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
;##################################
; Script
;##################################
ProgressSet (50 , "E-Mail wird versendet!")
$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
ProgressSet (100 , "Fertig!")
Sleep (100)
MsgBox (64,"Mp3-Player","E-Mail erfolgreich versendet!")
ProgressOff ()
EndFunc
;
; 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
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_Senden ()
EndSwitch
WEnd
|
Ich hab erstmal alles durch 'Test' ersetzt.
kannst du mir helfen wie die 2 inputboxen ausgelesen werden können?
zur hilfe der original script
Quote:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: XXlolimanxx
Script Function:
Liest den Text aus einer Editbox einer Gui aus und sendet es per E-Mail
#ce ----------------------------------------------------------------------------
Global $SmtpServer , $FromName , $FromAddress , $ToAddress , $Subject , $ssl , $oMyRet , $HexNumber , $oMyError
#Include<file.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1 = GUICreate("test", 497, 355, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPW INDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
$Edit1 = GUICtrlCreateEdit("", 8, 4, 477, 281)
GUICtrlSetData(-1, "Geb hier eine Nachricht ein.")
$Button1 = GUICtrlCreateButton("test", 84, 288, 353, 57, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func _Senden ()
ProgressOn ("Mp3-Player","E-Mail wird versendet! Bitte warten!","Einstellungen auslesen.",-1,-1,2)
$Bericht = GUICtrlRead ($Edit1)
;
;##################################
; Include
;##################################
;##################################
; Variables
;##################################
$SmtpServer = "mail.gmx.net" ; address for the smtp-server to use - REQUIRED
$FromName = "-" ; name from who the email was sent
$FromAddress = "[email protected]" ; address from where the mail should come
$ToAddress = "[email protected]" ; destination address of the email - REQUIRED
$Subject = "-" ; subject from the email - can be anything you want it to be
$Body = $Bericht ; 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 = "[email protected]" ; 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
$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
;##################################
; Script
;##################################
ProgressSet (50 , "E-Mail wird versendet!")
$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
ProgressSet (100 , "Fertig!")
Sleep (100)
MsgBox (64,"Mp3-Player","E-Mail erfolgreich versendet!")
ProgressOff ()
EndFunc
;
; 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
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_Senden ()
EndSwitch
WEnd
|
Mit dem orig. script funktioniert alles prima doch ich weiß jetzt nicht wie ich es bei meinem machen soll?
|
|
|
09/09/2010, 21:24
|
#12
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
So?!
Code:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: XXlolimanxx
Script Function:
Liest den Text aus einer Editbox einer Gui aus und sendet es per E-Mail
#ce ----------------------------------------------------------------------------
Global $SmtpServer , $FromName , $FromAddress , $ToAddress , $Subject , $ssl , $oMyRet , $HexNumber , $oMyError
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 358, 278, 232, 156)
$Label1 = GUICtrlCreateLabel("Test", 24, 8, 313, 35)
GUICtrlSetFont(-1, 20, 400, 0, "Make Juice")
$Label2 = GUICtrlCreateLabel("test", 16, 56, 17, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("test", 16, 88, 22, 17)
$input1 = GUICtrlCreateInput("", 48, 56, 97, 21)
$input2 = GUICtrlCreateInput("", 48, 96, 97, 21)
$Exp = GUICtrlCreateLabel("test", 16, 152, 31, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$HP = GUICtrlCreateLabel("test", 16, 184, 26, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$MP = GUICtrlCreateLabel("test", 16, 216, 27, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 56, 152, 17, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 56, 184, 17, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 56, 216, 17, 17)
$DMG = GUICtrlCreateLabel("test", 184, 152, 42, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 248, 152, 17, 17)
$Button1 = GUICtrlCreateButton("test", 200, 208, 137, 49, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func _Senden ()
ProgressOn ("Test","Test E-Mail wird versendet! Bitte warten!","Einstellungen auslesen.",-1,-1,2)
$Bericht = GUICtrlRead ($Edit1)
;
;##################################
; Include
;##################################
;##################################
; Variables
;##################################
$SmtpServer = "mail.gmx.net" ; address for the smtp-server to use - REQUIRED
$FromName = "jonas" ; name from who the email was sent
$FromAddress = "[email protected]" ; address from where the mail should come
$ToAddress = "[email protected]" ; destination address of the email - REQUIRED
$Subject = "test" ; subject from the email - can be anything you want it to be
$Body = $Bericht ; 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 = "[email protected]" ; 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
$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
;##################################
; Script
;##################################
ProgressSet (50 , "E-Mail wird versendet!")
$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
ProgressSet (100 , "Fertig!")
Sleep (100)
MsgBox (64,"Mp3-Player","E-Mail erfolgreich versendet!")
ProgressOff ()
EndFunc
;
; 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
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$i1 = guictrlread($input1)
$i2 = guictrlread($input2)
MsgBox("","","input1:"&$i1&@CRLF&"input2:"&$i2)
_Senden ()
EndSwitch
WEnd
|
|
|
09/09/2010, 21:49
|
#13
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
naja jetzzt passirt dieser error mit dem script:
Error: Variable used without being declared.
und wenn ich unten hinschreibe :
$Bericht = GUICtrlRead ($input1, $input2)
kommt das gleiche....
also ist da eine variable nicht erkläert oder?
|
|
|
09/10/2010, 08:21
|
#14
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
schau mal in Zeile 45, da wird $Bericht deklariert. Das ist noch ein restbestand von den Original Script.
Bitte probier die Fehlermeldungen zu verstehen und deuten zu können, da wird dir nähmlich schon viel geholfen wenn du Syntax fehler hast.
|
|
|
09/10/2010, 13:17
|
#15
|
elite*gold: 0
Join Date: Apr 2010
Posts: 431
Received Thanks: 138
|
mh ich hab kA was das zu bedueten hat... was muss ich da ändern?
So hab nene neuen error:
the request action with this object has failed -> Der Antrag der Aktion mit diesem Objekt ist fehlgeschlagen
Wenn ich den script so aussehen lasse:
Code:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: XXlolimanxx
Script Function:
Liest den Text aus einer Editbox einer Gui aus und sendet es per E-Mail
#ce ----------------------------------------------------------------------------
Global $SmtpServer , $FromName , $FromAddress , $ToAddress , $Subject , $ssl , $oMyRet , $HexNumber , $oMyError
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 358, 278, 232, 156)
$Label1 = GUICtrlCreateLabel("Test", 24, 8, 313, 35)
GUICtrlSetFont(-1, 20, 400, 0, "Make Juice")
$Label2 = GUICtrlCreateLabel("test", 16, 56, 17, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("test", 16, 88, 22, 17)
$input1 = GUICtrlCreateInput("", 48, 56, 97, 21)
$input2 = GUICtrlCreateInput("", 48, 96, 97, 21)
$Exp = GUICtrlCreateLabel("test", 16, 152, 31, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$HP = GUICtrlCreateLabel("test", 16, 184, 26, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$MP = GUICtrlCreateLabel("test", 16, 216, 27, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 56, 152, 17, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 56, 184, 17, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 56, 216, 17, 17)
$DMG = GUICtrlCreateLabel("test", 184, 152, 42, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 248, 152, 17, 17)
$Button1 = GUICtrlCreateButton("test", 200, 208, 137, 49, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func _Senden ()
ProgressOn ("Test","Test E-Mail wird versendet! Bitte warten!","Einstellungen auslesen.",-1,-1,2)
$Bericht = GUICtrlRead ($input1, $input2)
;
;##################################
; Include
;##################################
;##################################
; Variables
;##################################
$SmtpServer = "mail.gmx.net" ; address for the smtp-server to use - REQUIRED
$FromName = "j-" ; name from who the email was sent
$FromAddress = "[email protected]" ; address from where the mail should come
$ToAddress = "-" ; destination address of the email - REQUIRED
$Subject = "test" ; subject from the email - can be anything you want it to be
$Body = $Bericht ; 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 = "[email protected]" ; 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
$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
;##################################
; Script
;##################################
ProgressSet (50 , "E-Mail wird versendet!")
$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
ProgressSet (100 , "Fertig!")
Sleep (100)
MsgBox (64,"Mp3-Player","E-Mail erfolgreich versendet!")
ProgressOff ()
EndFunc
;
; 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
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$i1 = guictrlread($input1)
$i2 = guictrlread($input2)
MsgBox("","","input1:"&$i1&@CRLF&"input2:"&$i2)
_Senden ()
EndSwitch
WEnd
Findest du den fehler?
|
|
|
Similar Threads
|
Probelm bei CF
06/18/2010 - CrossFire - 1 Replies
HiHo
Ich habe ein Probelm ich habe mir grade CF runter geladen und installiert
Dann öffne ich das und dann patch er ja aber danb sagt er also der patcher:
Failes to download patchfiled was soll man da jz machen?
|
Probelm
03/27/2010 - Metin2 Private Server - 1 Replies
Hi
ich suche da pw von navicat den code für das pw 12345 kann den jemand vilt posteb
|
hp probelm
10/19/2009 - Metin2 Private Server - 0 Replies
hi ich habe eine seite aufgemacht mit xampp und so mist aber wenn ich da rein gehe kommt da fehler beim verbinden mit dem server und so scheisse was ist das probelm ich hahbe hamachi an xampp an und den server auch an sogar navicat aber geht immernoch nicht was soll ich tun
|
Probelm
10/08/2009 - Metin2 PServer Guides & Strategies - 1 Replies
Bei meinen Instante Files sind keine vmc. datein vorhanden.
Wiso?
MFG
|
got a probelm
05/25/2009 - CO2 Private Server - 4 Replies
#Request Close
|
All times are GMT +2. The time now is 04:18.
|
|