AceLoc Posted October 2, 2006 Share Posted October 2, 2006 expandcollapse popup$a = "mail.alpha.org:1845";SMTP $b = "Bill_Gates@Microsoft.com";SENDER $c = "MY_EMAIL@hotmail.com";DESTINATION $d = "Hello";SUBJECT $e = "Testing this script now.";TEXT $f = "";LOGFILE _EmailSend($a, $b, $c, $d, $e, $f) Func _EmailSend($SMTP, $SENDER, $DEST, $SUBJECT, $TEXT, $LOGFILE) ; This func is a email sender. You just need to keep a copy of blat.exe ; in the script folder that will be FileInstall()ed and used. ; This script has been tested with the lite version, but it should works with other too. ; ; $SMTP is smtp address, use a : to divide the port and @lf to divide Auth login and pass. ; e.g. Server : mail.alpha.org:1845 ; AuthLogin: I am me ; AuthPass : Secret ; will become ; _EmailSend('mail.alpha.org:1845' & @lf & 'I am me' & @lf & 'Secret',...ect...) ; Of course Auth parameters must be used togheter and they are not mandatory. ; $SENDER is the sender address. ; $DEST is the destination addresses list. (comma separated) ; $SUBJECT is the Subject line. ; $TEXT is the email main text. It may be a filename or the message itself. ; - if you put directly the text use the @crlf as new line char. Be careful ; about the 4096 char limit of AutoIt lines. ; - if you use a file its content will become exatly the mail text, as binary. ; $LOGFILE is a filename where append the logfile. If omitted (left '') the log ; won't be created. ; Returns ; 1 All should be OK. ; -1 A blat error. The log is shown in a MsgBox with a 10 second timeout. ; -2 Badly formatted $SMTP ; -3 No @ in the sender address ; -4 No @ in the destination address ; -5 No text ; -6 No installed blat.exe Local $SMTP, $SENDER, $DEST, $SUBJECT, $TEXT, $LOGFILE, $LOG, $H = -1, $C, $E Local $SMTPSERVER, $AUTHLOGIN = '', $AUTHPASS = '', $QUOTE = '' If Not FileExists(@TempDir & '\~blattmp.exe') Then Return -6 If @OSTYPE = 'WIN32_NT' Then $QUOTE = '"' ;Check Smtp server If StringInStr($SMTP, @LF) Then $SMTP = StringSplit($SMTP, @LF) If Not $SMTP[0] = 3 Then Return -2 $SMTPSERVER = $SMTP[1] $AUTHLOGIN = $SMTP[2] $AUTHPASS = $SMTP[3] Else $SMTPSERVER = $SMTP EndIf ;Check addresses If Not StringInStr($SENDER, '@') Then Return -3 If Not StringInStr($DEST, '@') Then Return -4 ;Check subject If $SUBJECT = '' Then $SUBJECT = ' -ss ' Else $SUBJECT = ' -s "' & $SUBJECT & '" ' EndIf ;Check Text Select Case $TEXT = '' Return -5 Case Not FileExists($TEXT) FileDelete(@TempDir & '\~mailtext.tmp') FileWrite(@TempDir & '\~mailtext.tmp', $TEXT) $TEXT = (@TempDir & '\~mailtext.tmp') Case Else ; $Text file exists and will be used as mail text. EndSelect FileDelete(@TempDir & '\~maillog.txt') ;Sending! If IsArray($SMTP) Then;There is Authlogin $E = RunWait(@ComSpec & ' /c ' & $quote & '"' & @TempDir & '\~blattmp.exe" "' & $TEXT & _ '" -to ' & $DEST & ' -binary -server ' & $SMTPSERVER & ' -log ' & @TempDir & _ '\~maillog.txt -timestamp -f ' & $SENDER & $SUBJECT & '-u ' & $AUTHLOGIN & _ ' -pw ' & $AUTHPASS & '"', @TempDir, @SW_HIDE) Else ;There is NOT Authlogin $E = RunWait(@ComSpec & ' /c ' & $quote & '"' & @TempDir & '\~blattmp.exe" "' & $TEXT & _ '" -to ' & $DEST & ' -binary -server ' & $SMTPSERVER & ' -log ' & @TempDir & _ '\~maillog.txt -timestamp -f ' & $SENDER & $SUBJECT & '"', @TempDir, @SW_HIDE) EndIf $LOG = FileRead(@TempDir & '\~maillog.txt', FileGetSize(@TempDir & '\~maillog.txt')) If $LOGFILE <> '' Then $H = FileOpen($LOGFILE, 1) EndIf If $H <> - 1 Then;$H is -1 both if the user didn't ask for a logfile or ; if it is impossible to write in it. FileWrite($H, $LOG) FileClose($H) EndIf FileDelete(@TempDir & '\~maillog.txt') FileDelete(@TempDir & '\~mailtext.tmp') If $E <> 0 Then MsgBox(16, 'Blat log. Errors.', $LOG, 10) Return -1 EndIf Return 1 EndFunc ;==>_EmailSend Func OnAutoItStart() ;Install blat.exe (lite version) FileInstall('blat.exe', @TempDir & '\~blattmp.exe', 1) EndFunc ;==>OnAutoItStart Func OnAutoItExit() ;Delete blat.exe FileDelete(@TempDir & '\~blattmp.exe') EndFunc ;==>OnAutoItExit ehmm gettin error why? Thnk [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 2, 2006 Moderators Share Posted October 2, 2006 (edited) http://www.autoitscript.com/forum/index.ph...st&p=244717If it don't work for you, why not make it yourself? Edited October 2, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
AceLoc Posted October 2, 2006 Author Share Posted October 2, 2006 http://www.autoitscript.com/forum/index.ph...st&p=244717If it don't work for you, why not make it yourself? because i cant copy a 'non -standard' Func [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 2, 2006 Moderators Share Posted October 2, 2006 because i cant copy a 'non -standard' Func Such a dumbass. Anyway, this line doesn't look right, but I'll let your brilliant mind figure out why.'\~maillog.txt -timestamp -f ' & $SENDER & $SUBJECTBecause obviously your smarter than the rest of us. The reason I say that is you ask why something errors, and we have no way of running it to find out. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
AceLoc Posted October 2, 2006 Author Share Posted October 2, 2006 (edited) and we have no way of running it to find out.i dont think that its that.. because: i get this error: Line 52 Local $SMTP, $SENDER, $DEST, $SUBJECT, $TEXT, $LOGFILE, $LOG, $H = -1, $C, $E Local^ERROR Error: Can not redeclare a parameter inside a user function. Edited October 2, 2006 by AceLoc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 2, 2006 Moderators Share Posted October 2, 2006 Because?.. (Thanks btw.)If you can't figure that out looking at your own script, then you're more lost than I thought. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 2, 2006 Moderators Share Posted October 2, 2006 i dont think thats its that.. i get this error: Line 52 Local $SMTP, $SENDER, $DEST, $SUBJECT, $TEXT, $LOGFILE, $LOG, $H = -1, $C, $E Local^ERROR Error: Can not redeclare a parameter inside a user function.Do you know what a parameter is? Hint: _EmailSend($SMTP, $SENDER, $DEST, $SUBJECT, $TEXT, $LOGFILE)See the variables between the parenthesis? Those are parameters, they are already local, then you try to redeclare them here: Local $SMTP, $SENDER, $DEST, $SUBJECT, $TEXT, $LOGFILE, $LOG, $H = -1, $C, $EGuess what happens when you remove them from that line completely? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
AceLoc Posted October 2, 2006 Author Share Posted October 2, 2006 Do you know what a parameter is? Hint: _EmailSend($SMTP, $SENDER, $DEST, $SUBJECT, $TEXT, $LOGFILE)See the variables between the parenthesis? Those are parameters, they are already local, then you try to redeclare them here: Guess what happens when you remove them from that line completely? I couldnt know that.. the guy who made them see: http://www.autoitscript.com/forum/index.php?showtopic=4892 Said that was the correctly one. (Topic is really old though.) Well.. Thanks for helping [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now