Fran Posted April 15, 2011 Share Posted April 15, 2011 Hi,I downloaded and implemented this UDF.But I can't get the email to work.I've added InetMail to the UDF so I can send the bug report to my email address.I have a problem though with the variable $sErrDesc. If I put everything in the body except for this line, it works fine. But the moment I add the $sErrDesc, it gives me this message:"The command line argument is not valid. Verify the switch you are using."I've added >>>>>>>>>>>>>>>>>>>>>>>> to the line I have a problem with.#include <AutoItErrorHandler_UDF.au3> GUICreate("AutoIt Error Handler Example", 350, 200) ;~ GUICtrlCreateLabel("This script is just an example." & @LF & @LF & "It will produce a syntax error in", 25, 40, 300, 50) ;~ GUICtrlCreateLabel("5", 185, 50, 50, 40) ;~ GUICtrlSetColor(-1, 0xF20000) ;~ GUICtrlSetFont(-1, 30, 1000) ;~ GUICtrlCreateLabel("seconds.", 220, 67, 300, 50) ;~ GUICtrlCreateLabel(StringFormat("The result shown as a CUSTOM error message, you can change it!"), 25, 120, 350, 80) ;~ GUICtrlCreateLabel("Copyright jennico, G.Sandler (MrCreatoR) © 2008", 25, 170, 350, 80) ;~ GUICtrlSetColor(-1, 0x808080) ;~ GUICtrlSetFont(-1, 8.5, 800, 6) GUISetState() ;~ For $i = 5 To 1 Step -1 ;~ GUICtrlSetData(4, $i) ;~ Sleep(1000) ;~ Next MsgBox(0, "") ;We deliberately make a syntax mistake (one parameter missing) and call the error! MsgBox(0,"","rest of script")Save this script as AutoItErrorHandler_UDF.au3 and then run the example above.expandcollapse popup#NoTrayIcon #include-once #include <StaticConstants.au3> #include <INet.au3> _AutoItErrorHandler() Func _AutoItErrorHandler($sTitleMsg = -1, $sErrorMsgFormat = -1) If StringInStr($CmdLineRaw, "/AutoIt3ExecuteScript") Then Opt("TrayIconHide", 0) Return EndIf Local $sErrorMsg = "" Local $hErrGUI, $nMsg, $SendReport_Label, $SendReport_Icon, $ShowBugReport_Label, $ShowBugReport_Icon Local $ContinueApp_Label, $ContinueApp_Icon, $RestartApp_Label, $RestartApp_Icon, $CloseApp_Label, $CloseApp_Icon Local $sRunLine = @AutoItExe & ' /ErrorStdOut /AutoIt3ExecuteScript "' & @ScriptFullPath & '"' Local $iPID = Run($sRunLine, @ScriptDir, 0, 2 + 4) ProcessWait($iPID) While 1 $sErrorMsg &= StdoutRead($iPID) If @error Then ExitLoop Sleep(10) WEnd If $sErrorMsg = "" Then Exit If Not IsString($sTitleMsg) Then $sTitleMsg = "RapidStudio Error Message" If Not IsString($sErrorMsgFormat) Then $sErrorMsgFormat = "Program has been Terminated :(.\r\n" & _ "Please report about this bug to the author, sorry for the inconvenience!\r\n\r\n" & _ "Program Path: %s\r\n\r\nError Line: %s\r\n\r\nError Description: %s" Local $labelbgW = 131, $labelbgH = 22, $labelbgT = 34 + 50, $labelbgColor = 0xFFFFFF, $labelbgColor2 = 0x999999 Local $labelW = 115, $labelH = 15, $labelT = $labelbgT + 4 Local $iconW = 16, $iconH = 16, $iconT = $labelbgT + 3 Local $g = 15 Local $label1L = $g + 17, $label2L = $label1L + $labelbgW + $g, $label3L = $label2L + $labelbgW + $g, $label4L = $label3L + $labelbgW + $g Local $labelbg1L = $g, $labelbg2L = $labelbg1L + $labelbgW + $g, $labelbg3L = $labelbg2L + $labelbgW + $g, $labelbg4L = $labelbg3L + $labelbgW + $g Local $icon1L = $g + 3, $icon2L = $icon1L + $labelbgW + $g, $icon3L = $icon2L + $labelbgW + $g, $icon4L = $icon3L + $labelbgW + $g $hErrGUI = GUICreate($sTitleMsg, $labelbg4L + $labelbgW + $g, 120, -1, -1, -2134376448) ;BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) WinSetOnTop($hErrGUI, "", 1) GUISetIcon("User32.dll", -1) GUICtrlCreateIcon("user32.dll", 103, 11, 11, 32, 32) GUICtrlSetBkColor(GUICtrlCreateLabel('An error occurred in the application. First try to "Restart" the application.' & @CRLF & 'If the problem persists, please contact support.', 52, 22, 518, 30), -2) #Region Label 1 $RestartApp_Frame = GUICtrlCreateLabel("", $labelbg1L - 1, $labelbgT - 1, $labelbgW + 2, $labelbgH + 2, $SS_BLACKFRAME) GUICtrlSetCursor(-1, 0) GUICtrlSetBkColor(GUICtrlCreateLabel("", $labelbg1L, $labelbgT, $labelbgW, $labelbgH), $labelbgColor2) GUICtrlSetState(-1, 128) $RestartApp_Label = GUICtrlCreateLabel(" Restart application", $label1L, $labelT, $labelW, $labelH) GUICtrlSetBkColor(-1, -2) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetCursor(-1, 0) $RestartApp_Icon = GUICtrlCreateIcon("shell32.dll", 255, $icon1L, $iconT, 16, 16) GUICtrlSetCursor(-1, 0) #EndRegion Label 1 #Region Label 2 $CloseApp_Frame = GUICtrlCreateLabel("", $labelbg2L - 1, $labelbgT - 1, $labelbgW + 2, $labelbgH + 2, $SS_BLACKFRAME) GUICtrlSetCursor(-1, 0) GUICtrlSetBkColor(GUICtrlCreateLabel("", $labelbg2L, $labelbgT, $labelbgW, $labelbgH), $labelbgColor) GUICtrlSetState(-1, 128) $CloseApp_Label = GUICtrlCreateLabel(" Close application", $label2L, $labelT, $labelW, $labelH) GUICtrlSetBkColor(-1, -2) GUICtrlSetCursor(-1, 0) $CloseApp_Icon = GUICtrlCreateIcon("shell32.dll", 240, $icon2L, $iconT, 16, 16) GUICtrlSetCursor(-1, 0) #EndRegion Label 2 #Region Label 3 $SendReport_Frame = GUICtrlCreateLabel("", $labelbg3L - 1, $labelbgT - 1, $labelbgW + 2, $labelbgH + 2, $SS_BLACKFRAME) GUICtrlSetCursor(-1, 0) GUICtrlSetBkColor(GUICtrlCreateLabel("", $labelbg3L, $labelbgT, $labelbgW, $labelbgH), $labelbgColor) GUICtrlSetState(-1, 128) $SendReport_Label = GUICtrlCreateLabel(" Send bug report", $label3L, $labelT, $labelW, $labelH) GUICtrlSetBkColor(-1, -2) GUICtrlSetCursor(-1, 0) $SendReport_Icon = GUICtrlCreateIcon("shell32.dll", -157, $icon3L, $iconT, 16, 16) GUICtrlSetCursor(-1, 0) #EndRegion Label 3 #Region Label 4 $ShowBugReport_Frame = GUICtrlCreateLabel("", $labelbg4L - 1, $labelbgT - 1, $labelbgW + 2, $labelbgH + 2, $SS_BLACKFRAME) GUICtrlSetCursor(-1, 0) GUICtrlSetBkColor(GUICtrlCreateLabel("", $labelbg4L, $labelbgT, $labelbgW, $labelbgH), $labelbgColor) GUICtrlSetState(-1, 128) $ShowBugReport_Label = GUICtrlCreateLabel(" Show bug report", $label4L, $labelT, $labelW, $labelH) GUICtrlSetBkColor(-1, -2) GUICtrlSetCursor(-1, 0) $ShowBugReport_Icon = GUICtrlCreateIcon("shell32.dll", 23, $icon4L, $iconT, 16, 16) GUICtrlSetCursor(-1, 0) #EndRegion Label 4 DllCall("user32.dll", "int", "MessageBeep", "int", 0x00000010) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $SendReport_Label, $SendReport_Icon, $SendReport_Frame $sErrorMsgFormat = "Program has been Terminated :(.\r\n" & _ "\r\n\r\n" & _ "Program Path: %s\r\n\r\nError Line: %s\r\n\r\n" & _ "Error Description: %s\r\n\r\n" $sScriptPath = StringRegExpReplace($sErrorMsg, "(?s)\A(.*) \(\d+\) : ==> .*", "\1") $iScriptLine = StringRegExpReplace($sErrorMsg, "(?s)\A.* \((\d+)\) : ==> .*", "\1") $sErrDesc = StringRegExpReplace($sErrorMsg, "(?s)\A.* \(\d+\) : ==> (.*)", "\1") If @Compiled Then $sScriptPath = @ScriptFullPath ;$iScriptLine = "N/A" $sErrDesc = StringRegExpReplace($sErrorMsg, '(?s).*: ==> (.*):', '\1') EndIf $Address = 'joesoap@email.com' $Subject = 'RS Bug Report: Install Downloader' $bodyline1 = "Program has been Terminated :(." $bodyline2 = "Program Path: " & $sScriptPath $bodyline3 = "Error Line: " & $iScriptLine $bodyline4 = "Error Description: " & $sErrDesc ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Problem!!!! "The command line argument is not valid. Verify the switch you are using." _INetMail($Address, $Subject, $bodyline1 & @crlf & $bodyline2 & @CRLF & $bodyline3 & @CRLF & $bodyline4) ;~ MsgBox(262144 + 64, "Send Bug Report", "Here we can sent an Email with the bug report!", 0, $hErrGUI) Case $ShowBugReport_Label, $ShowBugReport_Icon, $ShowBugReport_Frame $sScriptPath = StringRegExpReplace($sErrorMsg, "(?s)\A(.*) \(\d+\) : ==> .*", "\1") $iScriptLine = StringRegExpReplace($sErrorMsg, "(?s)\A.* \((\d+)\) : ==> .*", "\1") $sErrDesc = StringRegExpReplace($sErrorMsg, "(?s)\A.* \(\d+\) : ==> (.*)", "\1") If @Compiled Then $sScriptPath = @ScriptFullPath ;$iScriptLine = "N/A" $sErrDesc = StringRegExpReplace($sErrorMsg, '(?s).*: ==> (.*):', '\1') EndIf MsgBox(262144 + 4096, $sTitleMsg, StringFormat($sErrorMsgFormat, $sScriptPath, $iScriptLine, $sErrDesc), 0, $hErrGUI) Case $RestartApp_Label, $RestartApp_Icon, $RestartApp_Frame $sRunLine = @AutoItExe & ' "' & @ScriptFullPath & '"' If @Compiled Then $sRunLine = @ScriptFullPath Run($sRunLine, @ScriptDir) Exit Case $CloseApp_Label, $CloseApp_Icon, $CloseApp_Frame, -3 Exit EndSwitch WEnd Exit EndFunc ;==>_AutoItErrorHandler Link to comment Share on other sites More sharing options...
JScript Posted April 16, 2011 Share Posted April 16, 2011 (edited) Try use: _INetSmtpMail() instead of _INetMail()Worked for me... Edited April 16, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Fran Posted April 20, 2011 Author Share Posted April 20, 2011 Try use: _INetSmtpMail() instead of _INetMail()Worked for me...I can't use SMTP mail. I don't know the users' email account or server settings. 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