Mosquitos Posted November 26, 2006 Share Posted November 26, 2006 (edited) Hello, Can somebody tell me please whats wrong with this script? expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #include<File.au3> Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $GUI = GUICreate("Send Email", 350, 325, -1, -1) GUISetBkColor(0xff) $Smtp = GUICtrlCreateLabel("Smtp :", 5, 7, 70) GUICtrlSetColor($Smtp, 0xFFFFFF) GUICtrlSetFont($Smtp, 14) $From = GUICtrlCreateLabel("From :", 5, 37, 70) GUICtrlSetColor($From, 0xFFFFFF) GUICtrlSetFont($From, 14) $To = GUICtrlCreateLabel("To :", 5, 67, 70) GUICtrlSetColor($To, 0xFFFFFF) GUICtrlSetFont($To, 14) $Name = GUICtrlCreateLabel("Name :", 5, 97, 70) GUICtrlSetColor($Name, 0xFFFFFF) GUICtrlSetFont($Name, 14) $Attachlabel = GUICtrlCreateLabel("Attatch:", 5, 127, 70) GUICtrlSetColor($Attachlabel, 0xFFFFFF) GUICtrlSetFont($Attachlabel, 14) $Subjectlabel = GUICtrlCreateLabel("Subject :", 5, 157, 70) GUICtrlSetColor($Subjectlabel, 0xFFFFFF) GUICtrlSetFont($Subjectlabel, 14) $Username = GUICtrlCreateLabel("User :", 5, 187, 70) GUICtrlSetColor($Username, 0xFFFFFF) GUICtrlSetFont($Username, 14) $Password = GUICtrlCreateLabel("Pass :", 5, 217, 70) GUICtrlSetColor($Password, 0xFFFFFF) GUICtrlSetFont($Password, 14) $Bodylabel = GUICtrlCreateLabel("Body :", 5, 260, 70) GUICtrlSetColor($Bodylabel, 0xFFFFFF) GUICtrlSetFont($Bodylabel, 14) $mailserver = GUICtrlCreateInput("",83,5,262,25) GUICtrlSetFont($mailserver, 14) $youremail = GUICtrlCreateInput("",83,35,262,25) GUICtrlSetFont($youremail, 14) $toaddressin = GUICtrlCreateInput("",83,65,262,25) GUICtrlSetFont($toaddressin, 14) $yourname = GUICtrlCreateInput("",83,95,262,25) GUICtrlSetFont($yourname, 14) $attatchin = GUICtrlCreateInput("", 83, 125, 192, 25) GUICtrlSetFont($attatchin, 14) $subjectin = GUICtrlCreateInput("",83,155,262,25) GUICtrlSetFont($subjectin, 14) $body = GuiCtrlCreateEdit("",83,245,262,75, 0x50231104) GUICtrlSetFont($body, 14) $username = GUICtrlCreateInput("",83,185,262,25) GUICtrlSetFont($username, 14) $password = GUICtrlCreateInput("",83,215,262,25, $ES_PASSWORD) GUICtrlSetFont($password, 14) $browse = GUICtrlCreateButton("Browse", 280, 125, 65, 25) GUICtrlSetFont($browse, 11, 700) $Send = GUICtrlCreateButton("Send", 9, 295, 65, 25) GUICtrlSetFont($Send, 11, 700) GUISetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $browse GuiCtrlSetData($attatchin,FileOpenDialog("Attatch Files","","All Files(*.*)",4)) Case $msg = $Send $toaddress=GUICtrlRead($toaddressin) $attatch=GUICtrlRead($attatchin) $subject=GUICtrlRead($subjectin) $bodymsg=GUICtrlRead($body) $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch,"","",$username,$password)) EndSelect WEnd Exit If @error Then MsgBox(0,"Error sending message","Error code:" & @error & " Description:" & $rc) EndIf Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "" , $s_Username = "", $s_Password = "") $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" $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]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x] 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 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 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 $objEmail.Configuration.Fields.Update $objEmail.Send if @error then SetError(2) return $oMyRet[1] EndIf EndFunc 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) Return EndFunc Edited November 26, 2006 by Mosquitos Sapiente vince, rex, noli vincere ferro! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 26, 2006 Moderators Share Posted November 26, 2006 A rather general question... do we tell you what we think about your code, or do you have a specific question that you would like to be answered so we can narrow down where you want us to look without the crystal ball? 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...
Mosquitos Posted November 26, 2006 Author Share Posted November 26, 2006 A rather general question... do we tell you what we think about your code, or do you have a specific question that you would like to be answered so we can narrow down where you want us to look without the crystal ball?It gives me this error $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch,"","",$username,$password)) $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch,"","",^ ERROR Sapiente vince, rex, noli vincere ferro! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 26, 2006 Developers Share Posted November 26, 2006 It gives me this error $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch,"","",$username,$password)) $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch,"","",^ ERRORNo error in listed here ...But one thing i see at first glance is that $username is the handle of the Control and not its value... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Mosquitos Posted November 26, 2006 Author Share Posted November 26, 2006 No error in listed here ...But one thing i see at first glance is that $username is the handle of the Control and not its value... Zeg dat eens in het nederlands want dat versta ik niet Sapiente vince, rex, noli vincere ferro! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 26, 2006 Developers Share Posted November 26, 2006 (edited) Zeg dat eens in het nederlands want dat versta ik niet Je post een error maar er zit geen error beschrijving in jou post.Bij de definitie van $Username:$Username = GUICtrlCreateLabel("User :", 5, 187, 70)bevat $Username de Handle voor de Control maar niet de waarde die de control bevat.Om die te krijgen doe je : GUICtrlRead($username) ... Edited November 26, 2006 by JdeB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
/dev/null Posted November 26, 2006 Share Posted November 26, 2006 It gives me this error $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch,"","",$username,$password)) $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch,"","",^ ERRORwell, you pass more arguments than you have defined with the function declaration!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Mosquitos Posted November 27, 2006 Author Share Posted November 27, 2006 (edited) It's working now but i want something else then msgbox :"> expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #include<File.au3> Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $GUI = GUICreate("Send Email", 350, 325, -1, -1) GUISetBkColor(0x00008B) $Smtp = GUICtrlCreateLabel("Smtp :", 5, 7, 70) GUICtrlSetColor($Smtp, 0xFFFFFF) GUICtrlSetFont($Smtp, 14) $From = GUICtrlCreateLabel("From :", 5, 37, 70) GUICtrlSetColor($From, 0xFFFFFF) GUICtrlSetFont($From, 14) $To = GUICtrlCreateLabel("To :", 5, 67, 70) GUICtrlSetColor($To, 0xFFFFFF) GUICtrlSetFont($To, 14) $Name = GUICtrlCreateLabel("Name :", 5, 97, 70) GUICtrlSetColor($Name, 0xFFFFFF) GUICtrlSetFont($Name, 14) $Attachlabel = GUICtrlCreateLabel("Attatch:", 5, 127, 70) GUICtrlSetColor($Attachlabel, 0xFFFFFF) GUICtrlSetFont($Attachlabel, 14) $Subjectlabel = GUICtrlCreateLabel("Subject :", 5, 157, 70) GUICtrlSetColor($Subjectlabel, 0xFFFFFF) GUICtrlSetFont($Subjectlabel, 14) $Usernamelabel = GUICtrlCreateLabel("User :", 5, 187, 70) GUICtrlSetColor($Usernamelabel, 0xFFFFFF) GUICtrlSetFont($Usernamelabel, 14) $Passwordlabel = GUICtrlCreateLabel("Pass :", 5, 217, 70) GUICtrlSetColor($Passwordlabel, 0xFFFFFF) GUICtrlSetFont($Passwordlabel, 14) $Bodylabel = GUICtrlCreateLabel("Body :", 5, 260, 70) GUICtrlSetColor($Bodylabel, 0xFFFFFF) GUICtrlSetFont($Bodylabel, 14) $mailserverin = GUICtrlCreateInput("",83,5,262,25) GUICtrlSetFont($mailserverin, 14) $youremailin = GUICtrlCreateInput("",83,35,262,25) GUICtrlSetFont($youremailin, 14) $toaddressin = GUICtrlCreateInput("",83,65,262,25) GUICtrlSetFont($toaddressin, 14) $yournamein = GUICtrlCreateInput("",83,95,262,25) GUICtrlSetFont($yournamein, 14) $attatchin = GUICtrlCreateInput("", 83, 125, 192, 25) GUICtrlSetFont($attatchin, 14) $subjectin = GUICtrlCreateInput("",83,155,262,25) GUICtrlSetFont($subjectin, 14) $body = GuiCtrlCreateEdit("",83,245,262,75, 0x50231104) GUICtrlSetFont($body, 14) $usernamein = GUICtrlCreateInput("",83,185,262,25) GUICtrlSetFont($usernamein, 14) $passwordin = GUICtrlCreateInput("",83,215,262,25, $ES_PASSWORD) GUICtrlSetFont($passwordin, 14) $browse = GUICtrlCreateButton("Browse", 280, 125, 65, 25) GUICtrlSetFont($browse, 11, 700) $Send = GUICtrlCreateButton("Send", 9, 295, 65, 25) GUICtrlSetFont($Send, 11, 700) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $browse GuiCtrlSetData($attatchin,FileOpenDialog("Attatch Files","","All Files(*.*)",4)) Case $msg = $Send $mailserver = GUICtrlRead($mailserverin) $yourname = GUICtrlRead($yournamein) $youremail = GUICtrlRead($youremailin) $username = GUICtrlRead($usernamein) $password = GUICtrlRead($passwordin) $toaddress = GUICtrlRead($toaddressin) $attatch = GUICtrlRead($attatchin) $subject = GUICtrlRead($subjectin) $bodymsg = GUICtrlRead($body) $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch, $username, $password) EndSelect WEnd Func _INetSmtpMailCom($s_SmtpServer = "", $s_FromName = "", $s_FromAddress = "", $s_ToAddress = "", $s_Subject = "", $as_Body = "", $s_AttachFiles = "" , $s_Username = "", $s_Password = "") $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" $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]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x] 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 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 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 $objEmail.Configuration.Fields.Update $objEmail.Send if @error then SetError(2) return $oMyRet[1] Else MsgBox(4096,"", "Message was sent.") EndIf EndFunc 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) Return EndFuncIs it possible to have a progressbar like this and when the email is sent that it shows 100% Edited November 27, 2006 by Mosquitos Sapiente vince, rex, noli vincere ferro! 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