Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/10/2013 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. Kilmatead

    _GetReparseTarget

    ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetReparseTarget ; Description....: Resolves a Reparse-Point (Junction, Symbolic Link or Mount Point) to its target and returns that destination path ; Syntax.........: _GetReparseTarget ( $sLink[, $AbsPath = True] ) ; Parameters.....: $sLink - Full path to a Reparse-Point object ; $AbsPath - Return an absolute path when link ID type is 2 (embedded relative path Symbolic Link) ; ; Return values..: Success - The path/filename of the target location ; ; @extended returns the ID/type of the Reparse-Point itself: ; 0 - Unknown/Unresolved ; 1 - Symbolic Link (embedded Absolute-Path) ; 2 - Symbolic Link (embedded Relative-Path) - primary return value will be an absolute path via the $sLink container (set $AbsPath = False to return the relative path) ; 3 - Junction Point ; 4 - Mount Point - primary return value will be the Globally Unique Identifier (GUID) as \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\ ; ; Failure - Empty string ("") and sets the @error flag: ; 1 - $sLink Not Found ; 2 - Unable to Open $sLink ; 3 - $sLink is not a Reparse-Point ; 4 - Unresolveable (Corrupted Tag / No Target details) ; ; Author.........: Kilmatead ; Modified.......: ; Remarks........: @Extended may still contain a valid ID even if the link itself failed resolution ; ; The $AbsPath parameter has no effect beyond relative path Symbolic Links (ID 2) ; ; No check is made to see if the resolved target folder or file actually exists, as even though the target-destination may have been renamed/removed or is temporarily ; unavailable, that doesn't invalidate the data integrity of the reparse-tag itself, especially when it may contain relative-path references ; ; Permission-Free access is used to open the link so as to resolve even System Links (as found in Vista+) - this can be misleading, as it does not indicate that using ; $sLink directly in the script outside of this function will likely fail as System Links have ACL's which deny access to everyone ; ; Related........: ; Link...........: ; Example........: ; =============================================================================================================================== #include <APIConstants.au3> #include <File.au3> #include <WinAPIEx.au3> Func _GetReparseTarget($sLink, $AbsPath = True) Local Enum $ID_UNKNOWN, $ID_SYMLINK, $ID_SYMLINK_RELATIVE, $ID_JUNCTION, $ID_MOUNT_POINT Local Enum $NOTFOUND = 1, $ACCESSDENIED, $NOTREPARSE, $NOTRESOLVED Local $tFindData = DllStructCreate($tagWIN32_FIND_DATA) Local $hFile = _WinAPI_FindFirstFile($sLink, DllStructGetPtr($tFindData)) ; Retrieve the attributes / verify existence / obtain the ReparseTag identifier If @error Then Return SetError($NOTFOUND, $ID_UNKNOWN, "") _WinAPI_FindClose($hFile) If BitAND(DllStructGetData($tFindData, "dwFileAttributes"), $FILE_ATTRIBUTE_REPARSE_POINT) Then Local Const $IO_REPARSE_TAG_SYMLINK = 0xA000000C Local Const $IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003 Local $Ret = "", $TypeID = $ID_UNKNOWN Local $Tag = _WinAPI_LoWord(DllStructGetData($tFindData, "dwReserved0")) Local $tREPARSE_GUID_DATA_BUFFER = _ "dword ReparseTag;" & _ "word ReparseDataLength;" & _ "word Reserved; " & _ "word SubstituteNameOffset;" & _ "word SubstituteNameLength;" & _ "word PrintNameOffset;" & _ "word PrintNameLength;" Select Case BitAND($Tag, $IO_REPARSE_TAG_SYMLINK) $TypeID = $ID_SYMLINK $tREPARSE_GUID_DATA_BUFFER &= "dword Flags;" ; Convert (default) struct MountPointReparseBuffer to struct SymbolicLinkReparseBuffer Case BitAND($Tag, $IO_REPARSE_TAG_MOUNT_POINT) $TypeID = $ID_JUNCTION Case Else Return SetError($NOTRESOLVED, $ID_UNKNOWN, "") EndSelect $hFile = _WinAPI_CreateFileEx($sLink, $OPEN_EXISTING, 0, BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE, $FILE_SHARE_DELETE), _ ; dwDesiredAccess 0 (permission-free) BitOR($FILE_FLAG_BACKUP_SEMANTICS, $FILE_FLAG_OPEN_REPARSE_POINT)) If @error Then Return SetError($ACCESSDENIED, $TypeID, "") Local $RGDB = DllStructCreate($tREPARSE_GUID_DATA_BUFFER & "wchar PathBuffer[4096]") _WinAPI_DeviceIoControl($hFile, $FSCTL_GET_REPARSE_POINT, 0, 0, DllStructGetPtr($RGDB), DllStructGetSize($RGDB)) If Not @error Then Local Const $SYMLINK_FLAG_RELATIVE = 0x00000001 Local Const $SIZEOF_WCHAR = 2 Local $sBuffer = DllStructGetData($RGDB, "PathBuffer") ; Buffer "may" contain multiple strings "in any order" [MSDN]... Local $iOffset = DllStructGetData($RGDB, "SubstituteNameOffset") / $SIZEOF_WCHAR Local $iLength = DllStructGetData($RGDB, "SubstituteNameLength") / $SIZEOF_WCHAR $Ret = StringMid($sBuffer, 1 + $iOffset, $iLength) ; ...so always extract SubstituteName (despite its moniker) as the path-proper If StringLeft($Ret, 2) = "\?" Then $Ret = "\\" & StringMid($Ret, 3) ; DeviceIoControl loves substituting \??\ for more common \\?\, so we substitute it right back If $TypeID = $ID_SYMLINK And DllStructGetData($RGDB, "Flags") = $SYMLINK_FLAG_RELATIVE Then $TypeID = $ID_SYMLINK_RELATIVE If $Ret <> "" And $AbsPath Then $Ret = _PathFull($Ret, StringLeft($sLink, StringInStr($sLink, "\", 0, -1))) ; Convert to absolute path based from $sLink container EndIf Select ; Regulate possible mapped/unmapped UNC prefix genera or verify Mounted Volume ID by format Case StringRegExp($Ret, "(?i)\\Volume\{[a-f\d]{8}-([a-f\d]{4}-){3}[a-f\d]{12}\}\\$") ; "\Volume{GUID}\" $TypeID = $ID_MOUNT_POINT Case StringLeft($Ret, 8) = "\\?\UNC\" $Ret = StringReplace($Ret, "?\UNC\", "", 1) ; "\\?\UNC\server\share" -> "\\server\share" Case StringLeft($Ret, 4) = "\\?\" And StringMid($Ret, 6, 1) = ":" $Ret = StringTrimLeft($Ret, 4) ; "\\?\C:\FolderObject" -> "C:\FolderObject" EndSelect EndIf _WinAPI_CloseHandle($hFile) $RGDB = 0 If $Ret = "" Then Return SetError($NOTRESOLVED, $TypeID, "") Return SetExtended($TypeID, $Ret) EndIf Return SetError($NOTREPARSE, $ID_UNKNOWN, "") EndFunc Does what it says on the tin. Compatible with XP, Vista, Win7, etc. For a ridiculously long explanation on how it works (more or less for beginners with a sense of humour), and why GetFinalPathNameByHandle is not the way to go, and to see an extended example project it was created for, please see this. Simple example: #include "_GetReparseTarget.au3" $aList = _FileListToArray(@UserProfileDir) For $i = 1 To $aList[0] If BitAND(_WinAPI_GetFileAttributes(@UserProfileDir & "\" & $aList[$i]), $FILE_ATTRIBUTE_REPARSE_POINT) Then ConsoleWrite($aList[$i] & " >>>>> " & _GetReparseTarget(@UserProfileDir & "\" & $aList[$i]) & @LF) EndIf Next
    1 point
  3. Try making the numeric fields really numeric: Global $IPPort = number(IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "IPPort", Default)) ; port used for sending the mail Global $ssl = Number(IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "ssl", Default)) ; enables/disables secure socket layer sending - put to 1 if using httpS Jos
    1 point
  4. Change it to this when dealing with strings. $html = _ "blahblahblah" & _ "blah blah blah"
    1 point
  5. jdelaney

    Slow down execution

    AdlibRegister ( "DelayActions",50 ) Func DelayActions() Sleep(20) EndFunc that's a small addition that does not require script changes (adding hard coded sleeps every few lines)
    1 point
  6. Before releasing the script remove the "MsgBox" line - it's only for debugging reasons
    1 point
  7. Or this one: #include <Date.au3> While 1 $sTime = _NowTime(4) If $sTime = "12:00" Or $sTime = "15:00" Or $sTime = "17:00" Or $sTime = "19:00" Then MsgBox(0, "", $sTime) EndIf Sleep(1000 * 60) ; wait a minute WEnd
    1 point
  8. The drawing is corrected by the gfx handle is moved approx. 20 px. down. Just use $hGUI = GUICreate("(Untitled)", 200, 220) and you will see it properly. Br UEZ
    1 point
  9. This works for me and lets you save the combined charts as a single JPG: $oExcel.ActiveSheet.Chartobjects.CopyPicture() ; Copy all chart objects of the active sheet to the clipboard as a single picture Global $oSheet = $oExcel.Worksheets.Add() ; Create a new temporary sheet Global $oChart = $oSheet.ChartObjects.Add(200, 200, 400, 400) ; Create a new empty chart $oChart.Activate() ; Activate this chart $oExcel.ActiveWorkBook.ActiveChart.Paste() ; Paste the picture from the clipboard _XLChart_ChartExport($oExcel.ActiveWorkBook.ActiveChart, @ScriptDir & "\SaddleMerged.jpg", "JPEG", False, True) ; Save the chart as JPG
    1 point
×
×
  • Create New...