Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/20/2022 in all areas

  1. ; ;################################## ; Include ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $SmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED $FromName = "Name" ; name from who the email was sent $FromAddress = "your@Email.Address.com" ; address from where the mail should come $ToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED $Subject = "Userinfo" ; subject from the email - can be anything you want it to be $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed $BccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "******" ; username for the account used from where the mail gets sent - REQUIRED $Password = "********" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required ;~ $SmtpServer = "smtp.gmail.com" ; GMAIL address for the smtp-server to use - REQUIRED ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAIL enables/disables secure socket layer sending - put to 1 if using https ;~ $SmtpServer = "smtp.office365.com" ; O365 address for the smtp-server to use - REQUIRED ;~ $IPPort=25 ; O365 port used for sending the mail ;~ $ssl=1 ; O365 enables/disables secure socket layer sending - put to 1 if using https ;~ SmtpServer = "smtp.mail.yahoo.com" ; Yahoo address for the smtp-server to use - REQUIRED ;~ $IPPort = 465 ; Yahoo port used for sending the mail ;~ $ssl = 1 ; Yahoo enables/disables secure socket layer sending - put to 1 if using https ;################################## ; Script ;################################## 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, $tls) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; ; The UDF 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, $tls = 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 ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ;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 Edit: Fixed Bcc ... Edit: Added support for different port and SLL which are used by GMail (Port 465) Edit: Added Importance support (10/2008) EDIT: Added $TLS option (07/2020 Some interesting Info from the thread:
    1 point
  2. 1 point
  3. Remember arrays are zero based so you need to use $arrayButtonVars[2], basic example: #include <GUIConstantsEx.au3> Global $g_aButtons[3][2] = [["","Button 1"],["","Button 2"],["","Button 3"]] Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 105, 95) $g_aButtons[0][0] = GUICtrlCreateButton($g_aButtons[0][1], 10, 10, 85, 25) $g_aButtons[1][0] = GUICtrlCreateButton($g_aButtons[1][1], 10, 35, 85, 25) $g_aButtons[2][0] = GUICtrlCreateButton($g_aButtons[2][1], 10, 60, 85, 25) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $g_aButtons[0][0] To $g_aButtons[2][0] MsgBox(4096, "Button", GUICtrlRead($nMsg)) EndSwitch WEnd GUIDelete($hGUI) EndFunc
    1 point
  4. This is a full HTTP server written in pure AutoIt. No external libraries are used. The server code is readable and very simple to modify. Abilities: A full web server in a single executable. Able to integrate the web pages into your source code and modify its contents with code. ( This is how the first web pages were build ) The ability to send a page with over 1000 images in under 5 seconds. Fully compatible with both Firefox, Internet Explorer 6 through 9, Chrome and Safari. Nearly every line is commented. It helps you understand the code easily, so that you may reuse it and add on new code with ease. GET, POST are both supported and even cookies and sessions are supported This is intended to be a base for any future projects that provide any service over HTTP. Three different servers give you the base code that you need, and nothing you won't need. In the download there is included a short guide on how to choose the right one. BrettF has done some awesome work and added to capability to retain sessions in this post: >http://www.autoitscript.com/forum/topic/...e-autoit/page__view__findpost_ If you need sessions, you can use his version. This version is added in the above v1.1 download. Edit: Please find the webserver attached to this post. You guys keep eating my bandwidth and I had to move it again. webserver_011.zip
    1 point
  5. Hi guys, I needed a simple function to download files and show the progress of the download. I commented a bit (don't know if i should have added more) You can provide the url to the file, the wanted file name, the visible name for in the download progress UI, where the file should be downloaded to, if the progressbar should be hidden at the end of the function or if it should remain visible, how long the last message (completed/failed) should show and last but not least, a title for the progress window. At the end of the function you either get the full path of the download file or false when it fails with @error set and @extended set with the error code of the download. #include <InetConstants.au3> Func _webDownloader($sSourceURL, $sTargetName, $sVisibleName, $sTargetDir = @TempDir, $bProgressOff = True, $iEndMsgTime = 2000, $sDownloaderTitle = "MyDownloader") ; Declare some general vars Local $iMBbytes = 1048576 ; If the target directory doesn't exist -> create the dir If Not FileExists($sTargetDir) Then DirCreate($sTargetDir) ; Get download and target info Local $sTargetPath = $sTargetDir & "\" & $sTargetName Local $iFileSize = InetGetSize($sSourceURL) Local $hFileDownload = InetGet($sSourceURL, $sTargetPath, $INET_LOCALCACHE, $INET_DOWNLOADBACKGROUND) ; Show progress UI ProgressOn($sDownloaderTitle, "Downloading " & $sVisibleName) ; Keep checking until download completed Do Sleep(250) ; Set vars Local $iDLPercentage = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) * 100 / $iFileSize, 0) Local $iDLBytes = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) / $iMBbytes, 2) Local $iDLTotalBytes = Round($iFileSize / $iMBbytes, 2) ; Update progress UI If IsNumber($iDLBytes) And $iDLBytes >= 0 Then ProgressSet($iDLPercentage, $iDLPercentage & "% - Downloaded " & $iDLBytes & " MB of " & $iDLTotalBytes & " MB") Else ProgressSet(0, "Downloading '" & $sVisibleName & "'") EndIf Until InetGetInfo($hFileDownload, $INET_DOWNLOADCOMPLETE) ; If the download was successfull, return the target location If InetGetInfo($hFileDownload, $INET_DOWNLOADSUCCESS) Then ProgressSet(100, "Downloading '" & $sVisibleName & "' completed") If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf Return $sTargetPath ; If the download failed, set @error and return False Else Local $errorCode = InetGetInfo($hFileDownload, $INET_DOWNLOADERROR) ProgressSet(0, "Downloading '" & $sVisibleName & "' failed." & @CRLF & "Error code: " & $errorCode) If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf SetError(1, $errorCode, False) EndIf EndFunc ;==>_webDownloaderLet me know what you think The test in my example is done with the installer for java 8 update 65 Example usage : $url = "http://javadl.sun.com/webapps/download/AutoDL?BundleId=111687" $file = "Java_8_Update_65.exe" $name = "Java 8 Update 65" $dir = @TempDir & "\MyDownloader" $installcommand = " /s STATIC=Disable AUTO_UPDATE=Disable WEB_JAVA=Enable WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=Disable EULA=Enable REBOOT=Disable SPONSORS=Disable" $test = _webDownloader($url, $file, $name, $dir, False) If $test Then ProgressSet(100, "Running silent installation...", "Installing " & $name) $exitCode = RunWait($test & $installcommand) If $exitCode = 0 Then ProgressSet(100, "Installation completed") If $exitCode <> 0 Then ProgressSet(0, "Installation failed" & @CRLF & "Exit code: " & $exitCode) Sleep(3000) ProgressOff() FileDelete($test) Else ProgressOff() EndIfGreetz _webDownloader.au3
    1 point
  6. This was made for someone that was using FileInstall() wrong and asking for help. Since FileInstall() doesn't allow wildcards, and you must use a string for the source, this simply lets you choose a directory that you want to install, allows you to pick the extension to install or just use the wild card, allows you to choose the destination path, and allows you to choose the flag. It will bring everything up in the edit box, and you can use the copy button to copy the data, then paste it to your script. <snip> Feel free to add, critique, whatever... it was just thrown together quickly. Edit: Fixed version. Edit: Added the option to exclude the drive and directory from 1st parameter of FileInstall. Edit - 2014/12/02 Updated code... uses _FileListToArrayRec to allow recursive option now. Also goes to the computer location rather than homedrive. Note: Yes, there is a recursive option to get all the folders/files, however, I did not add code to check the directory paths and making sure they were created, this was a brain fart moment. But I do not have time at the moment to screw around with that, so if you want recursive and want to keep them installed in their directory paths, you may need to do each folder individually without recurse mode. <snip> Edit2 - 2014/12/02 I think I've fixed the recursion issue, added the choice of saving the hierarchy of the folder, should create the directories for you. I tried this on a huge folder of .au3 files, everything looked right. #include <GUIConstantsEx.au3> #include <File.au3> Global $sMyComputerCLSID = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" Global $gsDirData = "" Global $ghMain = GUICreate('FileInstall Directory', 600, 380) Global $giOutPut = GUICtrlCreateEdit('', 10, 10, 580, 300) GUICtrlCreateLabel('Extension:', 20, 318, 50, 20, 0x001) Global $giExtension = GUICtrlCreateInput('*', 75, 315, 50, 20) GUICtrlCreateLabel('Destination Path:', 130, 318, 90, 20, 0x001) Global $giDestPath = GUICtrlCreateInput('@TempDir & "\"', 220, 315, 200, 20) GUICtrlCreateLabel('Flag:', 425, 318, 30, 20, 0x001) Global $giFlag = GUICtrlCreateCombo('', 455, 315, 40, 300) GUICtrlSetData($giFlag, '0|1|', '0') Global $giDirDrive = GUICtrlCreateCheckbox("Long Path", 500, 315) Global $giDirRecurse = GUICtrlCreateCheckbox("Dir Recurse", 500, 335) Global $giDirHierarchy = GUICtrlCreateCheckbox("Keep Hierarchy", 500, 355) Global $giGetDir = GUICtrlCreateButton('Directory Get Files', 110, 345, 150, 30) Global $giCopyData = GUICtrlCreateButton('Copy Data', 320, 345, 150, 30) GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit Case $giGetDir $gsDirData = _GetDirData(GUICtrlRead($giExtension), (GUICtrlRead($giDirDrive) <> 1), _ GUICtrlRead($giDestPath), GUICtrlRead($giFlag), GUICtrlRead($giDirRecurse), _ GUICtrlRead($giDirHierarchy) = $GUI_CHECKED) If Not @error Then GUICtrlSetData($giOutPut, '') GUICtrlSetData($giOutPut, $gsDirData) EndIf Case $giCopyData ClipPut(GUICtrlRead($giOutPut)) EndSwitch WEnd Func _GetDirData($sExt, $bExcludeLongName, $sDestPath, $nFlag, $nRecursive, $bHierarchy) Local $sDir = FileSelectFolder("Select a Directory to FileInstall", $sMyComputerCLSID) If @error Then Return SetError(1, @extended, "") EndIf $nRecursive = ($nRecursive = $GUI_CHECKED) ? 1 : 0 Local $aFiles = _FileListToArrayRec($sDir, "*." & $sExt, 1, $nRecursive, 0, 2) If Not IsArray($aFiles) Then Return SetError(2, @extended, "") EndIf Local $sTDrive, $sTDir, $sTFName, $sTExt Local $sHold = "" _GetExistStr($sDestPath, $sHold) Local $sFinstall = "" Local $sTmpDest = "" Local $sHoldStr = "" If $bHierarchy Then ; main folder searching _PathSplit($sDir, $sTDrive, $sTDir, $sTFName, $sTExt) If StringRight(StringRegExpReplace($sDestPath, "[\\/]+\z", ""), _ StringLen($sTFName)) <> $sTFName Then $sTmpDest = StringRegExpReplace($sDestPath, _ "(\&\s*(?:\x27|\x22)[\\/]+(?:\x27|\x22))", "") & ' & "\' & $sTFName & '\"' If Not StringInStr($sHoldStr, $sTDir & @LF) Then $sHoldStr &= $sTDir & @LF _GetExistStr($sTmpDest, $sHold) EndIf EndIf EndIf Local Static $sScrDir = StringRegExpReplace(@ScriptDir, "\\+\z", "") For $i = 1 To UBound($aFiles) - 1 $sTmpDest = $sDestPath _PathSplit($aFiles[$i], $sTDrive, $sTDir, $sTFName, $sTExt) If $bExcludeLongName Then If $sScrDir = StringRegExpReplace($sTDrive & $sTDir, "\\+\z", "") Then $aFiles[$i] = $sTFName & $sTExt EndIf EndIf If $bHierarchy Then $sTmpDest = StringRegExpReplace($sTmpDest, _ "(\&\s*(?:\x27|\x22)[\\/]+(?:\x27|\x22))", "") & ' & "' & $sTDir & '"' If Not StringInStr($sHoldStr, $sTDir & @LF) Then $sHoldStr &= $sTDir & @LF _GetExistStr($sTmpDest, $sHold) EndIf EndIf $sFinstall &= "FileInstall(""" & $aFiles[$i] & '", ' & $sTmpDest & ", " & $nFlag & ")" & @CRLF Next $sHold &= $sFinstall $sHold = StringTrimRight($sHold, 2) Return $sHold EndFunc Func _GetExistStr($sDestPath, ByRef $sOutData) $sOutData &= 'If Not FileExists(' & $sDestPath & ') Then' & @CRLF $sOutData &= ' Do' & @CRLF $sOutData &= ' DirCreate(' & $sDestPath & ')' & @CRLF $sOutData &= ' Until FileExists(' & $sDestPath & ')' & @CRLF $sOutData &= 'EndIf' & @CRLF EndFunc .
    1 point
  7. Sure , but why ask here and not with the companies causing this issue? This is the sticky thread for this "issue":
    0 points
×
×
  • Create New...