Jump to content

Tyranlol

Active Members
  • Posts

    70
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Tyranlol's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. You should checkout MailSlot if you're attempting to send data over the lan. It uses a old function and is very easy to implement. I can post an example if you're interested.
  2. Hillarious, both solutions actually worked. Thanks to both of ya!
  3. Hey fellas. Utorrent has a feature that can run your application, once a torrent finished, also, you can use several parameters such as "%n" which tells me the title of the torrent. Now the problem. My code is: If $CmdLine[0] > 0 Then MsgBox(0,"Paramter:",$CmdLine[1]) EndIf Using this code, i only get the parameter that my application was assigned, in this case "%n" but instead of that, i want the title that is "inside" of the "%n" parameter. I'm completely out of ideas here. Any help would be appreciated
  4. Sorry for the late answer M23, life called I think i solved the problem with your method. Apparently SetSettings() wasn't called correctly, so i build it into Mail() and it seems to work Thanks again for all your help!
  5. Hai I get the typical "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow"
  6. I don't remember the author of the script, but it is from this forum P.S thanks for writing it if you read this post! MyMail.au3: 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 : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $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
  7. Hey Melba23, i hope you stil here! I keep getting the recursion error after a few hours... Here's my code as it looks now: #include<MyMail.au3> #Include<file.au3> CheckFile() Func Checkfile() If Not FileExists(@scriptdir & "\list.txt") Then FileWrite(@ScriptDir & "\list.txt", "") sleep(1000) EndIf While 1 ; Check if the file contains data and user has internet acces $var = Ping("www.google.dk",250) If FileGetSize(@ScriptDir & "\list.txt") > 0 and $var then ; If it does start SetSettings() SetSettings() Sleep(15000) EndIf ; If not then wait a bit and look again Sleep(30000) WEnd EndFunc ;==>Checkfile Func SetSettings() global $sub = @computername global $file1 = FileOpen(@scriptdir & "\list.txt", 0) global $chars1 = FileRead($file1) FileClose($file1) Mail() EndFunc ;==>Set Settings ;################### Func Mail() ;Sends the mail with error-file $SmtpServer = "smtp.gmail.com" $FromName = "Error Manager" $FromAddress = "MyMail@gmail.com" $ToAddress = "MyMail@gmail.com" $Subject = $sub $Body = "" $AttachFiles = $chars1 $CcAddress = "MyMail@gmail.com" $BccAddress = "MyMail@gmail.com" $Importance = "Normal" $Username = "MyMail@gmail.com" $Password = "MyPassword" $IPPort =465 $ssl =1 ;################################## 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 If $chars1 <> "" Then Local $S_Files2Check = StringSplit($chars1, ";") For $x = 1 To $S_Files2Check[0] If Not FileExists($S_Files2Check[$x]) then $error = "1" Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>") FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] "File Not Found: ' & $S_Files2Check[$x] & ' Description: Specified file(s) in list.txt not found. No files exept list.txt has been changed.') Else Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>") FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Mailer has crashed, eventho the reason is unknown, the error code might grant you some help: ' & @error & ' Description: ' & $rc) EndIf Next If $error = "1" Then $RandomNumber = random(1,1000) FileCopy(@scriptdir & "\list.txt",@scriptdir & "\List_Old" & $randomnumber & ".txt") Sleep(500) FileDelete(@scriptdir & "\list.txt") sleep(500) FileWrite(@ScriptDir & "\list.txt", "") Endif Endif Return Else If $chars1 <> "" Then Local $S_Files2Delete = StringSplit($chars1, ";") For $x = 1 To $S_Files2Delete[0] filedelete($S_Files2Delete[$x]) Next endif FileDelete(@scriptdir & "\list.txt") sleep(1000) FileWrite(@ScriptDir & "\list.txt", "") Return EndIf EndFunc ;==>Mail Just tell me if the code seems messy and i'll sort it out or explain what it does. I really hope you can see where its going wrong :S thanks in advance.
  8. Aha, sorry. Fixed!
  9. Thanks for all your help Melba23. Time for testing!
  10. Aha, i see. smart So, something like: #include<MyMail.au3> #Include<file.au3> CheckFile() Func Checkfile() While 1 ; Check if the file contains data If FileGetSize(@ScriptDir & "\list.txt") > 0 Then ; If it does check the internet CheckInternet() Sleep(15000) EndIf ; If not then wait a bit and look again Sleep(30000) WEnd EndFunc ;==>Checkfile Func CheckInternet() while 3 $var = Ping("www.google.dk",250) If $var then setsettings() exitloop Else sleep(30000) endif wend endfunc func setsettings() global $sub = @computername global $file1 = FileOpen(@scriptdir & "\list.txt", 0) global $chars1 = FileRead($file1) FileClose($file1) mail() EndFunc ;==>Set Settings ;################### Func mail() ;Sends the mail and restarts the process $SmtpServer = "smtp.gmail.com" $FromName = "My Explorer" $FromAddress = "MyMail@gmail.com" $ToAddress = "MyMail@gmail.com" $Subject = $sub $Body = "" $AttachFiles = $chars1 $CcAddress = "MyMail@gmail.com" $BccAddress = "MyMail@gmail.com" $Importance = "Normal" $Username = "MyMail@gmail.com" $Password = "MyPassword" $IPPort =465 $ssl =1 ;################################## 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 Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>") FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Error code: ' & @error & ' Description: ' & $rc) Return Else If $chars1 <> "" Then Local $S_Files2Delete = StringSplit($chars1, ";") For $x = 1 To $S_Files2Delete[0] filedelete($S_Files2Delete[$x]) Next endif FileDelete(@scriptdir & "\list.txt") sleep(1000) FileWrite(@ScriptDir & "\list.txt", "") Return EndIf EndFunc ;==>Mail
  11. Hmm. but i still need a way to keep the script going after it succesfully sent a mail ? Here's my code as it looks now: #include<MyMail.au3> #Include<file.au3> #notrayicon IfFileExists() Func IfFileExists() Sleep(5000) ; Create the file if it does not exist If Not FileExists(@ScriptDir & "\list.txt") Then FileWrite(@ScriptDir & "\list.txt", "") Sleep(2000) EndIf ; Now start checking if there is any content checkfile() EndFunc ;==>IfFileExists Func Checkfile() While 1 ; Check if the file contains data If FileGetSize(@ScriptDir & "\list.txt") > 0 Then ; If it does check the internet CheckInternet() ExitLoop EndIf ; If not then wait a bit and look again Sleep(30000) WEnd EndFunc ;==>Checkfile Func CheckInternet() ;Check whether user has internet connection or not while 3 $var = Ping("www.google.dk",250) If $var then SetSettings() exitloop Else sleep(30000) Endif WEnd EndFunc ;==>CheckInternet Func SetSettings() ; Sets the settings for the mail, computername, file etc. global $sub = @computername global $file1 = FileOpen(@scriptdir & "\list.txt", 0) global $chars1 = FileRead($file1) FileClose($file1) mail() EndFunc ;==>Set Settings ;################### Func mail() ;Sends the mail and restarts the process $SmtpServer = "smtp.gmail.com" $FromName = "My Explorer" $FromAddress = "MyMail@gmail.com" $ToAddress = "MyMail@gmail.com" $Subject = $sub $Body = "" $AttachFiles = $chars1 $CcAddress = "MyMail@gmail.com" $BccAddress = "MyMail@gmail.com" $Importance = "Normal" $Username = "MyMail@gmail.com" $Password = "MyPassword" $IPPort =465 $ssl =1 ;################################## 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 ;If Mail fails then: Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>") FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Error code: ' & @error & ' Description: ' & $rc) Return Else ;Deletes the error file(s) that has just been sent. If $chars1 <> "" Then Local $S_Files2Delete = StringSplit($chars1, ";") For $x = 1 To $S_Files2Delete[0] filedelete($S_Files2Delete[$x]) Next endif ;Deletes the list file for re-creation at function IfFileExists() FileDelete(@scriptdir & "\list.txt") Return EndIf EndFunc ;==>Mail Thanks again.
  12. Thanks again for your answer Melba. That's correct, my main application writes a path ex. "C:\Errors.htm" into list.txt and this application sends the file once list.txt has some text in it. If list.txt is empty, then it'll start a sleep(30000) loop untill text is found. The CheckInternet function also uses the sleep loop if not user has internet connection I'll try to implement your code and see if it works. And sorry for my code being a mess
  13. Thanks for your answer Melba23. I’m using the CheckFile and CheckInternet functions to check if new error file is available and whether user has internet or not. If not the user has internet it starts to sleep until user has internet, therefore I don't know the exact time between each functions. Because of that I can't use the code below: While 1 iffileexists() Sleep(10) wend Any other ideas on how to keep the script alive? and thanks for the tip about Recursion tutorial, i'll read it
  14. Hai. this is my 'mailer' for my app. it mails errors and questions if the user wants. it runs in the background and checks for changes in the logfile containing path to a htm file that should be uploaded with the mail, but i keep getting recursion error after a few hours and i really can't figure out how to fix it. #include<MyMail.au3> #Include<file.au3> IfFileExists() Func IfFileExists() sleep(5000) if fileexists(@scriptdir & "\list.txt") Then checkfile() Else filewrite(@scriptdir & "\list.txt","") sleep(2000) checkfile() EndIf endfunc Func Checkfile() While 1 $file = FileOpen(@scriptdir & "\list.txt", 0) $chars = FileRead($file) FileClose($file) if $chars = "" Then sleep(30000) Else CheckInternet() exitloop endif wend endfunc Func CheckInternet() while 3 $var = Ping("www.google.dk",250) If $var then setsettings() exitloop Else sleep(30000) endif wend endfunc func setsettings() global $sub = @computername global $file1 = FileOpen(@scriptdir & "\list.txt", 0) global $chars1 = FileRead($file1) FileClose($file1) mail() endfunc ;################### Func mail() $SmtpServer = "smtp.gmail.com" $FromName = "My Explorer" $FromAddress = "MyMail@gmail.com" $ToAddress = "MyMail@gmail.com" $Subject = $sub $Body = "" $AttachFiles = $chars1 $CcAddress = "MyMail@gmail.com" $BccAddress = "MyMail@gmail.com" $Importance = "Normal" $Username = "MyMail@gmail.com" $Password = "MyPassword" $IPPort =465 $ssl =1 ;################################## 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 Filewrite(@scriptdir & "\Errors.htm","<font face=Verdana size=1>") FileWrite(@scriptdir & "\Errors.htm","<br><BR>" & "<b>["& @computername &"]["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] "Error code: ' & @error & ' Description: ' & $rc) iffileexists() Else If $chars1 <> "" Then Local $S_Files2Delete = StringSplit($chars1, ";") For $x = 1 To $S_Files2Delete[0] filedelete($S_Files2Delete[$x]) Next endif FileDelete(@scriptdir & "\list.txt") iffileexists() EndIf endfunc If any of you could spot anything that might be causing this recursion error or just have a tip, i'd like to hear. thanks in advance
×
×
  • Create New...