treyb Posted January 20, 2011 Share Posted January 20, 2011 Below is the code that I need help on. The scripts opens the .txt file and then reads each line comparing it the the active username. If the username is on the naughtyuser list, it will then email the details to the admins. When I leave out the email sending If statements the while loops works just fine. When I put it back in I get: "test1.au3 (40) : ==> "Wend" statement with no matching "While" statement.: Wend" can anyone help me fix this? #include <INet.au3> $file = FileOpen("c:\AT_naughtyuser.txt", 0) $time = "On: " & @MON & "-" & @MDAY & "-" & @YEAR & " at: " & @hour & ":" & @MIN If $file = -1 Then Exit EndIf While 1 $curline = FileReadLine($file) If @error = -1 Then ExitLoop $line = $curline if(@UserName = $line) Then $From = "email@server.com" $To = "email@server.com" $subject = "Login Detected: " & @UserName $body = "Login Detected: Username: " & @UserName & " Workstation: " & @ComputerName & " Time: " & $time $Username = "myemail@server.com" $Password = "mypassword" $Response = _INetSmtpMail ($From, $to, $subject, $body, $Username, $Password) $err = @error If $Response = 1 Then MsgBox(0, "Success!", "Mail sent") Else MsgBox(0, "Error!", "Mail failed with error code " & $err) EndIf ElseIf Wend FileClose($file) Link to comment Share on other sites More sharing options...
guinness Posted January 20, 2011 Share Posted January 20, 2011 (edited) Check Line 30 you are using ElseIf when it should be EndIf. Also I would recommend using the Full Version of SciTE4AutoIt3. Plus, have a look at _FileReadToArray() in the Help File too. Edited January 20, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
treyb Posted January 20, 2011 Author Share Posted January 20, 2011 Check Line 30 you are using ElseIf when it should be EndIf. Also I would recommend using the Full Version of SciTE4AutoIt3. Plus, have a look at _FileReadToArray() in the Help File too.DOH!!!!! I can not believe I missed that. I have been staring at it all day and couldn't see it.Now I am getting error code of 3 when I try to mail. What does that mean? and is there a page that has all the error codes on it? Link to comment Share on other sites More sharing options...
Mithrandir Posted January 20, 2011 Share Posted January 20, 2011 DOH!!!!! I can not believe I missed that. I have been staring at it all day and couldn't see it.Now I am getting error code of 3 when I try to mail. What does that mean? and is there a page that has all the error codes on it?It means it was unable to resolve the IP. You can get the error codes as well as examples and sintaxis of the functions in the Autoit Helpfile that comes with Scite4 More Info here: http://www.autoitscript.com/autoit3/scite/ Help with SOAP message!! Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 20, 2011 Share Posted January 20, 2011 Now I am getting error code of 3 when I try to mail. What does that mean? and is there a page that has all the error codes on it?Hi and Welcome to the forum!Open the helpfile and look at _INetSmtpMail()... What do you see?1 - Invalid Parameters 2 - Unable to start TCP 3 - Unable to resolve IP 4 - Unable to create socket 5x - Cannot open SMTP session. x indicates the index number of last command issued to the SMTP server. 50x - Cannot send body. x indicates the line number of $as_Body (first line is 0). 5000 - Cannot close SMTP session So what happens is "Unable to resolve IP". .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 20, 2011 Share Posted January 20, 2011 (edited) It means it was unable to resolve the IP. You can get the error codes as well as examples and sintaxis of the functions in the Autoit Helpfile that comes with Scite4 More Info here: http://www.autoitscript.com/autoit3/scite/No no no. There's no AutoIt stuff in the SciTE package. You get the AutoIt helpfile with AutoIt.But SciTE4AutoIt3 should of course be installed anyway. Fir the SciTE stuff.Edit: And don't call it SciTE4, that's just confusing. Edited January 20, 2011 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Mithrandir Posted January 21, 2011 Share Posted January 21, 2011 No no no. There's no AutoIt stuff in the SciTE package. You get the AutoIt helpfile with AutoIt.But SciTE4AutoIt3 should of course be installed anyway. Fir the SciTE stuff.Edit: And don't call it SciTE4, that's just confusing.Yep, you got a point there, the documentation he asked for comes with AutoIt. SciTE4Autoit is an editor in which is very easy to access to the helpfile among other things -like it predicts the functions you're going to use- that's why I got confused.Anyway, here is the online help (it doesn't seem to have the user defined functions though): http://www.autoitscript.com/autoit3/docs/And in case the OP doesn't have the helpfile for some reason (that was my first impression) : http://www.autoitscript.com/autoit3/downloads.shtml Help with SOAP message!! Link to comment Share on other sites More sharing options...
treyb Posted January 21, 2011 Author Share Posted January 21, 2011 Got it fixed. changed it from email to Smtp Server and it magically started working Thanx for all your help. The error code helped narrow it down alot. 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