Search the Community
Showing results for tags 'SMTP'.
-
Version 0.2024.10.11
44 downloads
I wanted to download a portable eMail server but didn't find one. So I wrote one that gets the eMail and ... nothing. It just changes the color of the tray icon. No users, no passwords, just send to this and it'll say, "ok: got it". My idea is like a SNMP (UDP) trap but for TCP. So you'd get the eMail alerts from the device ( TrueNAS in my case ) and ... keep'em there. Better than flooding you eMail box from your secured on-line eMail provider, when setup to send "info" instead of "warning" level information. Again, this just keeps them as dumps. But it may be a good start for your own coding Note: This accepts all that is thrown at it on port 25. For experimental local network use only. Installation and usage: ( for those running the compiled version ) Make a folder and drop the EXE there. Run it as user level ( no need for admin ). Let your firewall have traffic for the EXE and/or port 25 ( same I guess, I don't use firewalls ). Once running you'll see the icon in the tray area. Right click for the options menu, or double click the icon to open the message folder and reset the counter back to zero. You know that there is/are new messages by looking at the icon. If is color green ( no messages ), is color red ( new messages ). Mouse over the icon to see the last count of received messages. To uninstall, exit the EXE and delete the folder. -
I very long time was using In the end, I found that at present my needs I need to modify it. And here it is: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;~ #AutoIt3Wrapper_Run_Debug_Mode=Y ;(Y/N) Run Script with console debugging. Default=N #Region INCLUDE ;################################## ; Include ;################################## #include <file.au3> #EndRegion INCLUDE #Region Variables ;################################## ; Variables ;################################## Global Enum _ $g__INetSmtpMailCom_ERROR_FileNotFound = 1, _ $g__INetSmtpMailCom_ERROR_Send, _ $g__INetSmtpMailCom_ERROR_ObjectCreation, _ $g__INetSmtpMailCom_ERROR_COUNTER Global Const $g__cdoSendUsingPickup = 1 ; Send message using the local SMTP service pickup directory. Global Const $g__cdoSendUsingPort = 2 ; Send the message using the network (SMTP over the network). Must use this to use Delivery Notification Global Const $g__cdoAnonymous = 0 ; Do not authenticate Global Const $g__cdoBasic = 1 ; basic (clear-text) authentication Global Const $g__cdoNTLM = 2 ; NTLM ; Delivery Status Notifications Global Const $g__cdoDSNDefault = 0 ; None Global Const $g__cdoDSNNever = 1 ; None Global Const $g__cdoDSNFailure = 2 ; Failure Global Const $g__cdoDSNSuccess = 4 ; Success Global Const $g__cdoDSNDelay = 8 ; Delay Global Const $g__cdoDSNSuccessFailOrDelay = 14 ; Success, failure or delay #EndRegion Variables #Region Example Script ;################################## ; Example Script ;################################## ;~ _Example() Func _Example() Local $sSmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED Local $sFromName = "Name" ; name from who the email was sent Local $sFromAddress = "your@Email.Address.com" ; address from where the mail should come Local $sToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED Local $sSubject = "Userinfo" ; subject from the email - can be anything you want it to be Local $sBody = "" ; the messagebody from the mail - can be left blank but then you get a blank mail Local $sAttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed Local $sCcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed Local $sBccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed Local $sImportance = "Normal" ; Send message priority: "High", "Normal", "Low" Local $sUsername = "******" ; username for the account used from where the mail gets sent - REQUIRED Local $sPassword = "********" ; password for the account used from where the mail gets sent - REQUIRED Local $iIPPort = 25 ; port used for sending the mail Local $bSSL = False ; enables/disables secure socket layer sending - set to True if using httpS ; Local $iIPPort = 465 ; GMAIL port used for sending the mail ; Local $bSSL = True ; GMAIL enables/disables secure socket layer sending - set to True if using httpS Local $bIsHTMLBody = False Local $iDSNOptions = $g__cdoDSNDefault Local $rc = _INetSmtpMailCom($sSmtpServer, $sFromName, $sFromAddress, $sToAddress, $sSubject, $sBody, $sAttachFiles, $sCcAddress, $sBccAddress, $sImportance, $sUsername, $sPassword, $iIPPort, $bSSL, $bIsHTMLBody, $iDSNOptions) If @error Then MsgBox(0, "_INetSmtpMailCom(): Error sending message", _ "Error code: " & @error & @CRLF & @CRLF & _ "Error Hex Number: " & _INetSmtpMailCom_ErrHexNumber() & @CRLF & @CRLF & _ "Description: " & _INetSmtpMailCom_ErrDescription() & @CRLF & @CRLF & _ "Description (rc): " & $rc & @CRLF & @CRLF & _ "ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() _ ) ConsoleWrite("### COM Error ! Number: " & _INetSmtpMailCom_ErrHexNumber() & " ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() & " Description:" & _INetSmtpMailCom_ErrDescription() & @LF) EndIf EndFunc ;==>_Example #EndRegion Example Script #Region UDF Functions ; The UDF ; #FUNCTION# ==================================================================================================================== ; Name ..........: _INetSmtpMailCom ; Description ...: ; Syntax ........: _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[, $bSSL = False[, $bIsHTMLBody = False[, $iDSNOptions = $g__cdoDSNDefault]]]]]]]]]]]]) ; Parameters ....: $s_SmtpServer - A string value. ; $s_FromName - A string value. ; $s_FromAddress - A string value. ; $s_ToAddress - A string value. ; $s_Subject - [optional] A string value. Default is "". ; $s_Body - [optional] A string value. Default is "". ; $s_AttachFiles - [optional] A string value. Default is "". ; $s_CcAddress - [optional] A string value. Default is "". ; $s_BccAddress - [optional] A string value. Default is "". ; $s_Importance - [optional] A string value. Default is "Normal". ; $s_Username - [optional] A string value. Default is "". ; $s_Password - [optional] A string value. Default is "". ; $IPPort - [optional] An integer value. Default is 25. ; $bSSL - [optional] A binary value. Default is False. ; $bIsHTMLBody - [optional] A binary value. Default is False. ; $iDSNOptions - [optional] An integer value. Default is $g__cdoDSNDefault. ; Return values .: None ; Author ........: Jos ; Modified ......: mLipok ; Remarks .......: ; Related .......: http://www.autoitscript.com/forum/topic/23860-smtp-mailer-that-supports-html-and-attachments/ ; Link ..........: http://www.autoitscript.com/forum/topic/167292-smtp-mailer-udf/ ; Example .......: Yes ; =============================================================================================================================== Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $s_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $bSSL = False, $bIsHTMLBody = False, $iDSNOptions = $g__cdoDSNDefault) ; init Error Handler _INetSmtpMailCom_ErrObjInit() Local $objEmail = ObjCreate("CDO.Message") If Not IsObj($objEmail) Then Return SetError($g__INetSmtpMailCom_ERROR_ObjectCreation, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription()) ; Clear previous Err information _INetSmtpMailCom_ErrHexNumber(0) _INetSmtpMailCom_ErrDescription('') _INetSmtpMailCom_ErrScriptLine('') $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject ; Select whether or not the content is sent as plain text or HTM If $bIsHTMLBody Then $objEmail.Textbody = $s_Body & @CRLF Else $objEmail.HTMLBody = $s_Body EndIf ; Add Attachments 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 ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) Return SetError($g__INetSmtpMailCom_ERROR_FileNotFound, 0, 0) EndIf Next EndIf ; Set Email Configuration $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = $g__cdoSendUsingPort $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") = $g__cdoBasic $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.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = $bSSL ;Update Configuration 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 ; Set DSN options If $iDSNOptions <> $g__cdoDSNDefault And $iDSNOptions <> $g__cdoDSNNever Then $objEmail.DSNOptions = $iDSNOptions $objEmail.Fields.Item("urn:schemas:mailheader:disposition-notification-to") = $s_FromAddress ;~ $objEmail.Fields.Item("urn:schemas:mailheader:return-receipt-to") = $s_FromAddress EndIf ; Update Importance and Options fields $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then _INetSmtpMailCom_ErrObjCleanUp() Return SetError($g__INetSmtpMailCom_ERROR_Send, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription()) EndIf ; CleanUp $objEmail = "" _INetSmtpMailCom_ErrObjCleanUp() EndFunc ;==>_INetSmtpMailCom ; ; Com Error Handler Func _INetSmtpMailCom_ErrObjInit($bParam = Default) Local Static $oINetSmtpMailCom_Error = Default If $bParam == 'CleanUp' And $oINetSmtpMailCom_Error <> Default Then $oINetSmtpMailCom_Error = '' Return $oINetSmtpMailCom_Error EndIf If $oINetSmtpMailCom_Error = Default Then $oINetSmtpMailCom_Error = ObjEvent("AutoIt.Error", "_INetSmtpMailCom_ErrFunc") EndIf Return $oINetSmtpMailCom_Error EndFunc ;==>_INetSmtpMailCom_ErrObjInit Func _INetSmtpMailCom_ErrObjCleanUp() _INetSmtpMailCom_ErrObjInit('CleanUp') EndFunc ;==>_INetSmtpMailCom_ErrObjCleanUp Func _INetSmtpMailCom_ErrHexNumber($vData = Default) Local Static $vReturn = 0 If $vData <> Default Then $vReturn = $vData Return $vReturn EndFunc ;==>_INetSmtpMailCom_ErrHexNumber Func _INetSmtpMailCom_ErrDescription($sData = Default) Local Static $sReturn = '' If $sData <> Default Then $sReturn = $sData Return $sReturn EndFunc ;==>_INetSmtpMailCom_ErrDescription Func _INetSmtpMailCom_ErrScriptLine($iData = Default) Local Static $iReturn = '' If $iData <> Default Then $iReturn = $iData Return $iReturn EndFunc ;==>_INetSmtpMailCom_ErrScriptLine Func _INetSmtpMailCom_ErrFunc() _INetSmtpMailCom_ErrObjInit() _INetSmtpMailCom_ErrHexNumber(Hex(_INetSmtpMailCom_ErrObjInit().number, 8)) _INetSmtpMailCom_ErrDescription(StringStripWS(_INetSmtpMailCom_ErrObjInit().description, 3)) _INetSmtpMailCom_ErrScriptLine(_INetSmtpMailCom_ErrObjInit().ScriptLine) SetError(1); something to check for when this function returns Return EndFunc ;==>_INetSmtpMailCom_ErrFunc #EndRegion UDF Functions Creating this modification, I had to: 1. Object Error Handler used only for the duration of the function of Use, 2. Automatic ErrorHandler CleanUp so that previous ErrorHandler took the job. 3. Ability to get ErrorNumber and ErrorDescription ErrorScriptLine information even after the end of the function 4. Elimination of most global variables mLipok EDIT: attached SmtpMailer_UDF.au3 file EDIT 2: Any comments are welcome. EDIT 3: Script CleanUp EDIT 4: Download moved to "Download Section" (previously downloaded 379 times) EDIT 5: at 2016/01/31 there was many script breaking changes
-
This is modest beginning for UDF Chilkat component: https://www.chilkatsoft.com/downloads_ActiveX.asp Some of AcitveX object bundled into this component (dll file) are Free (you can verify it here), some other are commercial. You can downolad this UDF here: ; #INDEX# ======================================================================== ; Title .........: Chilkat.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: A collection of Function for use with Chilkat component ; Author ........: mLipok ; Modified ......: ; URL ...........: https://www.chilkatsoft.com/refdoc/activex.asp ; URL ...........: https://www.chilkatsoft.com/downloads_ActiveX.asp ; Date ..........: 2017/02/01 ; Version .......: 0.1.1 BETA - Work in progress ; ================================================================================ #cs 2017/02/01 . First official version - mLipok #ce http://www.chilkatforum.com/questions/1306/is-the-chilkat-upload-component-freeware Examples: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ;~ #AutoIt3Wrapper_Run_Debug_Mode=Y #Tidy_Parameters=/sort_funcs /reel #include <Array.au3> #include <StringConstants.au3> #include "Chilkat.au3" _Example() Func _Example() _ErrorLog_ChilkatWrapper(ConsoleWrite) _Chilkat_StartUp(@ScriptDir & '\ChilkatAx-9.5.0-win32.dll') _Chilkat_DllVersion($CHILKATOBJ_VERSION_950) Local $oGLOBAL = _Chilkat_GLOBAL_ObjCreate() If @error Then MsgBox($MB_ICONERROR, 'GLOBAL Declartion', '@error = ' & @error & @CRLF & '@extended = ' & @extended) _Chilkat_GLOBAL_UnlockBundle($oGLOBAL, "Anything for 30-day trial") If @error Then MsgBox($MB_ICONERROR, 'UnlockBundle', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Just comment / uncomment one of this followin Examples functions: ;~ _Example_12_JsonObject_PrettyPrint() ;~ _Example_13_JsonObject_IterateMembers() ;~ _Example_14_JsonObject_CreateDocument() ;~ _Example_15_CSV_ColumnNames() ;~ _Example_16_CSV_ToArray() _Example_17_CSV_ToArray('(?i).*?Pierwszy.*?Urz.*?Skarb.*?', '(?i).*Katowice.*?') EndFunc ;==>_Example Func _Example_12_JsonObject_PrettyPrint() _Log_ChilkatExample('_Example_12_JsonObject_PrettyPrint') ; https://www.example-code.com/vbscript/json_pretty_print.asp Local $oJSON = _Chilkat_JSON_ObjCreate() If @error Then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) Local $sJSON_String = "{""name"": ""donut"",""image"":{""fname"": ""donut.jpg"",""w"": 200,""h"": 200},""thumbnail"":{""fname"": ""donutThumb.jpg"",""w"": 32,""h"": 32}}" Local $iSuccess = $oJSON.Load($sJSON_String) If ($iSuccess <> 1) Then ConsoleWrite($oJSON.LastErrorText & @CRLF) Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) EndIf ; To pretty-print, set the EmitCompact property equal to 0 $oJSON.EmitCompact = 0 ; If bare-LF line endings are desired, turn off EmitCrLf ; Otherwise CRLF line endings are emitted. $oJSON.EmitCrLf = 0 ; Emit the formatted JSON: ConsoleWrite($oJSON.Emit() & @CRLF) EndFunc ;==>_Example_12_JsonObject_PrettyPrint Func _Example_13_JsonObject_IterateMembers() _Log_ChilkatExample('_Example_13_JsonObject_IterateMembers') ; https://www.example-code.com/vbscript/json_iterate_members.asp Local $oJSON = _Chilkat_JSON_ObjCreate() If @error Then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) Local $sJSON_String = "{ ""id"": 1, ""name"": ""A green door"", ""tags"": [""home"", ""green""], ""price"": 125 }" Local $iSuccess = $oJSON.Load($sJSON_String) If ($iSuccess <> 1) Then ConsoleWrite($oJSON.LastErrorText & @CRLF) Return SetError($CHILKAT_ERR_LOAD, @extended, $CHILKAT_RET_FAILURE) EndIf Local $sName = '', $sValue = '' Local $iNumMembers = $oJSON.Size, $iValue = 0 For $iMember_idx = 0 To $iNumMembers - 1 $sName = $oJSON.NameAt($iMember_idx) $sValue = $oJSON.StringAt($iMember_idx) ConsoleWrite($sName & ": " & $sValue & @CRLF) $iValue = $oJSON.IntAt($iMember_idx) ConsoleWrite($sName & " as integer: " & $iValue & @CRLF) Next EndFunc ;==>_Example_13_JsonObject_IterateMembers Func _Example_14_JsonObject_CreateDocument() _Log_ChilkatExample('_Example_14_JsonObject_CreateDocument') ; https://www.example-code.com/vbscript/create_json.asp Local $oJSON = _Chilkat_JSON_ObjCreate() If @error Then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) Local $iSuccess $iSuccess = $oJSON.AddStringAt(-1, "Title", "Pan's Labyrinth") ConsoleWrite("- $iSuccess=" & $iSuccess & @CRLF) $iSuccess = $oJSON.AddStringAt(-1, "Director", "Guillermo del Toro") ConsoleWrite("- $iSuccess=" & $iSuccess & @CRLF) $iSuccess = $oJSON.AddStringAt(-1, "Original_Title", "El laberinto del fauno") ConsoleWrite("- $iSuccess=" & $iSuccess & @CRLF) $iSuccess = $oJSON.AddIntAt(-1, "Year_Released", 2006) ConsoleWrite("- $iSuccess=" & $iSuccess & @CRLF) $oJSON.EmitCompact = 0 ConsoleWrite($oJSON.Emit() & @CRLF) EndFunc ;==>_Example_14_JsonObject_CreateDocument Func _Example_15_CSV_ColumnNames() _Log_ChilkatExample('_Example_15_CSV_ColumnNames') ; https://www.example-code.com/vbscript/csv_columnNames.asp Local $sURL = 'http://www.chilkatsoft.com/testData/sample.csv' InetGet($sURL, @ScriptDir & '\sample.csv') Local $oCSV = _Chilkat_CSV_ObjCreate() If @error Then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) ; Prior to loading the CSV file, indicate that the 1st row ; should be treated as column names: $oCSV.HasColumnNames = 1 ; Load the $oCSV records from the file: Local $iSuccess = $oCSV.LoadFile(@ScriptDir & "\sample.csv") If ($iSuccess <> 1) Then ConsoleWrite($oCSV.LastErrorText & @CRLF) Return SetError($CHILKAT_ERR_LOADFILE, @extended, $CHILKAT_RET_FAILURE) EndIf Local $iIndex = 0 Local $sColName = '' ; Display the column names: For $iCol_idx = 0 To $oCSV.NumColumns - 1 $sColName = $oCSV.GetColumnName($iCol_idx) ConsoleWrite($iCol_idx & ": " & $sColName & @CRLF) ; The following line demonstrates to to get the column ; index given a column name: $iIndex = $oCSV.GetIndex($sColName) ConsoleWrite($sColName & " is at column index " & $iIndex & @CRLF) Next EndFunc ;==>_Example_15_CSV_ColumnNames Func _Example_16_CSV_ToArray() _Log_ChilkatExample('_Example_16_CSV_ToArray') Local $sURL = 'http://www.chilkatsoft.com/testData/sample.csv' InetGet($sURL, @ScriptDir & '\sample.csv') Local $oCSV = _Chilkat_CSV_ObjCreate() If @error Then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) ; Prior to loading the CSV file, indicate that the 1st row ; should be treated as column names: $oCSV.HasColumnNames = 1 ; Load the $oCSV records from the file: Local $iSuccess = $oCSV.LoadFile(@ScriptDir & "\sample.csv") If ($iSuccess <> 1) Then ConsoleWrite($oCSV.LastErrorText & @CRLF) Return SetError($CHILKAT_ERR_LOADFILE, @extended, $CHILKAT_RET_FAILURE) EndIf Local $iNumColumns = $oCSV.NumColumns Local $iNumRows = $oCSV.NumRows Local $aResult[$iNumRows + 1][$iNumColumns] ; First get the column names For $iCol_idx = 0 To $iNumColumns - 1 $aResult[0][$iCol_idx] = $oCSV.GetColumnName($iCol_idx) Next For $iRow_idx = 0 To $iNumRows - 1 For $iCol_idx = 0 To $iNumColumns - 1 $aResult[$iRow_idx + 1][$iCol_idx] = $oCSV.GetCell($iRow_idx, $iCol_idx) Next Next _ArrayDisplay($aResult, '$aResult') EndFunc ;==>_Example_16_CSV_ToArray Func _Example_17_CSV_ToArray($sName_RegExpPattern, $sCity_RegExpPattern) _Log_ChilkatExample('_Example_16_CSV_ToArray') ; https://www.example-code.com/vbscript/csv_columnNames.asp Local $sURL = 'https://epuap.gov.pl/wps/wcm/connect/61e062b9-d981-4526-9f63-c2569263775a/RESP_2016-10-07.csv?MOD=AJPERES' InetGet($sURL, @ScriptDir & '\ePUAP.csv') ConsoleWrite("- Download completed" & @CRLF) Local $oCSV = _Chilkat_CSV_ObjCreate() If @error Then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) ; Prior to loading the CSV file, indicate that the 1st row ; should be treated as column names: $oCSV.HasColumnNames = 1 ; Load the $oCSV records from the file: Local $sCSVContent = FileRead(@ScriptDir & "\ePUAP.csv") ConsoleWrite("- Load File completed" & @CRLF) Local $iSuccess = $oCSV.LoadFromString($sCSVContent) If ($iSuccess <> 1) Then ConsoleWrite($oCSV.LastErrorText & @CRLF) Return SetError($CHILKAT_ERR_LOADFILE, @extended, $CHILKAT_RET_FAILURE) EndIf ConsoleWrite("- LoadFromString completed" & @CRLF) Local $iNumColumns = $oCSV.NumColumns Local $iNumRows = $oCSV.NumRows Local $aResult[$iNumRows + 1][$iNumColumns] ; First get the column names For $iCol_idx = 0 To $iNumColumns - 1 $aResult[0][$iCol_idx] = $oCSV.GetColumnName($iCol_idx) Next Local $iResult_RowCount = 1 ; First is ColumnName For $iRow_idx = 0 To $iNumRows - 1 If _ StringRegExp($oCSV.GetCell($iRow_idx, 0), $sName_RegExpPattern, $STR_REGEXPMATCH) _ And _ StringRegExp($oCSV.GetCell($iRow_idx, 4), $sCity_RegExpPattern, $STR_REGEXPMATCH) _ Then For $iCol_idx = 0 To $iNumColumns - 1 $aResult[$iResult_RowCount][$iCol_idx] = $oCSV.GetCell($iRow_idx, $iCol_idx) Next $iResult_RowCount += 1 EndIf Next ; strip array size to Number of founds rows ReDim $aResult[$iResult_RowCount][$iNumColumns] ConsoleWrite("- Parsing completed" & @CRLF) _ArrayDisplay($aResult, '$aResult') EndFunc ;==>_Example_17_CSV_ToArray Func _Log_ChilkatExample($sData) ConsoleWrite('>+ ' & $sData & @CRLF) EndFunc ;==>_Log_ChilkatExample REMARK: This UDF is a continuation of this thread:
- 16 replies
-
- chilkat
- pdfsigning
-
(and 3 more)
Tagged with:
-
This UDF was created to facilitate the saving and reading of email configuration. Thanks to @water, @jchd, @Jos for helping in translation of _EmailConfig_GUI_Preset_**() Hope to have _EmailConfig_GUI_Preset_ES() version soon. If you want to create your national version of _EmailConfig_GUI_Preset_**() please do not hesitate ... contribute. _EmailConfig_GUI_Preset_EN() is translated by me and Google Translator (from my national Polish language), so if you have any fix for this please do not hesitate ... contribute. The EmailConfig_Example_STMP_Mailer.au3 is using modified version of Jos SMTP Mailer UDF #AutoIt3Wrapper_UseX64=N #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel #include <Array.au3> #include <AutoItConstants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <Crypt.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "EmailConfig.au3" #include "GDPR.au3" ; https://www.autoitscript.com/forum/files/file/509-gdpr/ Global $oMyRet[2] #Region - EXAMPLE _MY_EXAMPLE__EmailConfig() Func _MY_EXAMPLE__EmailConfig() _GDPR_Crypter_Wrapper(_EmailConfig_ExampleCrypter) _EmailConfig_GUI_Preset_EN() ;~ _EmailConfig_GUI_Preset_DE() ;~ _EmailConfig_GUI_Preset_FR() ;~ _EmailConfig_GUI_Preset_NL() ;~ _EmailConfig_GUI_Preset_PL() _EmailConfig_SaveWrapper(_EmailConfig_SaveToINI) _EmailConfig_LoadWrapper(_EmailConfig_LoadFromINI) _EmailConfig_LoadWrapper() If $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, 'Question #' & @ScriptLineNumber, _ 'Do you want to set email configuration ?') Then _EmailConfig_ShowGUI() EndIf Local $s_ToAddress = 'whereisyourdestination@your.email.com' Local $s_Subject = 'Testing email sending : ' & @YEAR & @MON & @MDAY & ' ' & @HOUR & @MIN & @SEC Local $s_Body = 'This is only a test' Local $s_Attachments = '' _SMTP_SendEmail_Example($s_ToAddress, $s_Subject, $s_Body, $s_Attachments) EndFunc ;==>_MY_EXAMPLE__EmailConfig Func _EmailConfig_ExampleCrypter($dBinaryData, $bDataAlreadyEncrypted) _Crypt_Startup() ; Start the Crypt library. Local $dResult If $bDataAlreadyEncrypted Then $dResult = _Crypt_DecryptData($dBinaryData, 'securepassword', $CALG_AES_256) ; Decrypt the data using the generic password string. The return value is a binary string. Else $dResult = _Crypt_EncryptData($dBinaryData, 'securepassword', $CALG_AES_256) ; Encrypt the text with the new cryptographic key. EndIf _Crypt_Shutdown() ; Shutdown the Crypt library. Return $dResult EndFunc ;==>_EmailConfig_ExampleCrypter #EndRegion - EXAMPLE ; ; 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 $oCOM_Error_Handler = ObjEvent("AutoIt.Error", "MyErrFunc") #forceref $oCOM_Error_Handler Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 #forceref $i_Error Local $i_Error_desciption = "" #forceref $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 Func _SMTP_SendEmail_Example($s_ToAddress, $s_Subject, $s_Body, $s_Attachments) #Tidy_ILC_Pos=120 Local $aEMAIL_CONFIG = __EmailConfig__API() Local $SmtpServer = $aEMAIL_CONFIG[$EMAIL_CONFIG__22__SMTP_SERVER_NAME][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; address for the smtp-server to use - REQUIRED Local $FromName = $aEMAIL_CONFIG[$EMAIL_CONFIG__02__COMMON_NAME][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; name from who the email was sent Local $FromAddress = $aEMAIL_CONFIG[$EMAIL_CONFIG__03__EMAIL_ADDRESS][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; address from where the mail should come Local $ToAddress = $s_ToAddress ; destination address of the email - REQUIRED Local $Subject = $s_Subject ; subject from the email - can be anything you want it to be Local $Body = $s_Body ; the messagebody from the mail - can be left blank but then you get a blank mail Local $AttachFiles = $s_Attachments ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed Local $CcAddress = "" ; address for cc - leave blank if not needed Local $BccAddress = "" ; address for bcc - leave blank if not needed Local $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" Local $Username = $aEMAIL_CONFIG[$EMAIL_CONFIG__20__SMTP_USER_NAME][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; username for the account used from where the mail gets sent - REQUIRED Local $Password = $aEMAIL_CONFIG[$EMAIL_CONFIG__21__SMTP_PASSWORD][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; password for the account used from where the mail gets sent - REQUIRED Local $IPPort = $aEMAIL_CONFIG[$EMAIL_CONFIG__23__SMTP_PORT_NUMBER][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; port used for sending the mail ; in many country port 25 is not recomended, in such case use 587 instead Local $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS Local $tls = 0 ; enables/disables TLS when required ;~ Local $IPPort = 465 ; GMAIL port used for sending the mail ;~ Local $ssl = 1 ; GMAIL enables/disables secure socket layer sending - put to 1 if using httpS Local $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) If @error Then MsgBox(0, "Error sending email", "Error code: " & @error & @CRLF & "Description: " & $rc) EndIf EndFunc ;==>_SMTP_SendEmail_Example ; ; ; Com Error Handler Func MyErrFunc(ByRef $oMyError) Local $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 EmailConfig.au3 EmailConfig_Example_STMP_Mailer.au3
-
Today I want to share this little project made to check and notify the expiration of domain users password, in a Microsoft domain. Briefly, the script check users domain password expiration and takes actions. The script can work on multiple domain groups, taking different actions for every group, there is an .ini file with some options. Groups to be checked are defined in the .ini, and the groups must contain only users no other groups. The list of users of every group is obtained and if the password expiration in (remaining) days is matched (two possibilities) an email is sent. It can be a mail sent directly to the user (ini file : tomail=user) or it can be a mail sent to only one address (ini file : tomail=the@mail.it) (like domain admins...) and in this case the mail contains a report with the users approaching expiration. An operation log is always generated. In the ini (also the posted one) you can set to have no mail sent (for testing) and/or to have a GUI, but also the GUI is intended only for test, this script is scheduled on a server not logged in, so normally no GUI . Update 2018/03/16 : added switch to reset the password expiration, useful if you have for example an user (or 500) with psw expiration withing 3 days and you want to restore expiration within 90 days WITHOUT changing password. Used the way as advised by Microsoft (see the link), but with sth AD.au3 , the fantastic Active Directory UDF # First change the pwdlastset to 0 because Microsoft wants it this way $todouser.pwdLastSet = 0 Set-ADUser -Instance $todouser # Change the pwdlastset to the current date/time of the associate DC $todouser.pwdLastSet = -1 Set-ADUser -Instance $todouser Why you should act this way ? Big companies have strange policies listen to me ... The code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icone\Faenza\117.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; PEG ; Password Expiration Guardian ; (C) NSC 2018 ; check user domain password expiration and takes actions ; the script can work on multiple domain groups, taking differente actions for every group. ; the groups must contains only users no other groups ; the list of users of every group is obtained and if the password expiration in day is matched (two possibilities) an email is sent. ; It can be a mail sent directly to the user (ini file : tomail=user) ; or it can be a mail sent to only one address (ini file : tomail=the@mail.it) ; and in this case the mail contains a report with the users approaching expiration ; V.0.5 check based on one domain group ; V.1.0 ini file and check based on multiple domain groups ; V.1.5 ini file with general section to activate "test" GUI, and to enable disable mail send ; V.1.6 march 2018 italian "home made" translation of days and months in date ; V.1.7 added flag pwdLastSet to reset pass expiration - intended to use like a one time on/off switch to reset psw expiration #include <AD.au3> #include <File.au3> #include <GuiEdit.au3> #include <_zip.au3> #include <Date.au3> #include <Inet.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Debug.au3> Global $appname = "PEG", $appver = "V.1.7" Global $inifile = @ScriptDir & "\" & $appname & ".ini" Global $geleft = 5, $getop = 5, $gewidth = 790, $geheight = 540 Global $gollogcount = 0, $lastlog = "sicrlf", $cachelog = "", $guititle = "PEG " & $appver, $Gollogedit, $logfile = @ScriptDir & "\" & $appname & "_LOG_", $months2NOTzip = 3 Global $INIgroup, $INItomail, $INImailsubject, $INIsmpt, $INIfromname, $INIfromaddress, $INIdays1, $INIdays2, $INItosend, $arrayINIsections, $guiactive, $flagITA, $flagpwdLastSet ; START program GOLLOG(">>>>>> " & $appname & " " & $appver & " START >>>>>>") CFGctrl() If $guiactive = 1 Then GUI() $groupnumber = 0 While $groupnumber < $arrayINIsections[0] $groupnumber += 1 If $arrayINIsections[$groupnumber] <> "general" Then CFGload($arrayINIsections[$groupnumber]) loaduserS() EndIf WEnd If $guiactive = 1 Then While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GOLLOG("<<<< STOP <<<<") Exit EndSwitch WEnd EndIf GOLLOG("<<<<<< PEG STOP <<<<<<<") Exit ;STOP program Func GUI() GUICreate($guititle, 800, 560, 100, 200, -1) GUISetBkColor(0x693F54) ; will change background color $Gollogedit = GUICtrlCreateEdit("", $geleft, $getop, $gewidth, $geheight, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_BORDER, $WS_VSCROLL)) GUICtrlSetBkColor(-1, 0xC7BBC1) GUICtrlSetData(-1, "" & @CRLF) GUICtrlSetFont(-1, 9, 800, 0, "consolas") GUICtrlSetColor(-1, 0x090608) GUISetState(@SW_SHOW) GOLLOG("PEG " & $appver & " gui STARTED") EndFunc ;==>GUI Func loaduserS() GOLLOG("workin on group: " & $INIgroup) Local $Nscad = 0 Dim $report[1] = ["Report:"] Local $singlereport = "" Local $usermail = "" Local $username = "" Local $datediff = "" Local $arrayuserpsw Local $iErr _AD_Open() $search1 = _AD_GetGroupMembers($INIgroup) ;$search1 = _AD_RecursiveGetGroupMembers($INIgroup); testing recursive .. in the future maybe If @error = 0 Then Local $conta1 = 0 While $search1[0] > $conta1 $conta1 += 1 $arrayuserpsw = _AD_GetPasswordInfo($search1[$conta1]) $datediff = _DateDiff("D", _NowCalc(), $arrayuserpsw[9]) GOLLOG("USER: " & $search1[$conta1]) GOLLOG("Password expires on: " & $arrayuserpsw[9] & " in " & $datediff & " days") If $datediff = $INIdays1 Or $datediff = $INIdays2 Then GOLLOG("expiration match !") If $INItomail = "user" Then ; this IF is relative to .ini file parameter TOSEND $usermail = _AD_GetObjectAttribute($search1[$conta1], "mail") GOLLOG("sending mail to: " & $usermail) If $flagITA = 1 Then $dataITA = dataITA($arrayuserpsw[9]) Else $dataITA = _DateTimeFormat($arrayuserpsw[9], 1) EndIf Dim $report[1] = ["La tua password scadra' " & $dataITA & ", entro " & $datediff & " giorni."] _ArrayAdd($report, "Modificala per tempo !") If $INItosend = 0 Then GOLLOG("Not sent mail " & $Nscad & ": ") GOLLOG("from :" & $INIfromname & " | " & $INIfromaddress) GOLLOG("to :" & $usermail & " | subject: " & $INImailsubject) Local $reporttext = _ArrayToString($report) GOLLOG("text :" & $reporttext) Else Local $iResponse = _INetSmtpMail($INIsmpt, $INIfromname, $INIfromaddress, $usermail, $INImailsubject, $report, "EHLO " & @ComputerName, "-1") ; perla pearl mail send HS smtp (ehlo required) $iErr = @error If $iResponse = 1 Then GOLLOG("Success! " & "Mail to user sent") Else GOLLOG("Error! " & "Mail failed with error code " & $iErr) EndIf EndIf Else $username = _AD_GetObjectAttribute($search1[$conta1], "displayname") _ArrayAdd($report, "USER: " & $username) _ArrayAdd($report, "Password expires on: " & $arrayuserpsw[9] & " in " & $datediff & " days") $Nscad += 1 If $flagpwdLastSet = 1 Then ; warning : auto pass set GOLLOG("Re-set password expiration for " & $search1[$conta1]) If _AD_ModifyAttribute($search1[$conta1], "pwdLastSet", "0") Then GOLLOG("pwdLastSet to 0 - OK") Else GOLLOG("pwdLastSet to 0 - ERROR " & @error) EndIf If _AD_ModifyAttribute($search1[$conta1], "pwdLastSet", "-1") Then GOLLOG("pwdLastSet to -1 - OK") Else GOLLOG("pwdLastSet to -1 - ERROR " & @error) EndIf EndIf EndIf EndIf WEnd If $Nscad > 0 And $INItomail <> "user" Then _ArrayAdd($report, $Nscad & " user passwords near expiration") If $INItosend = 0 Then GOLLOG("Not sent mail " & $Nscad & ": ") GOLLOG("from :" & $INIfromname & " | " & $INIfromaddress) GOLLOG("to :" & $INItomail & " | subject: " & $INImailsubject) Local $reporttext = _ArrayToString($report) GOLLOG("text :" & $reporttext) Else Local $iResponse = _INetSmtpMail($INIsmpt, $INIfromname, $INIfromaddress, $INItomail, $INImailsubject, $report, "EHLO " & @ComputerName, "-1") ; perla pearl mail send HS smtp (ehlo required) Local $iErr = @error If $iResponse = 1 Then GOLLOG("Success! " & "Mail sent") Else GOLLOG("Error! " & "Mail failed with error code " & $iErr) EndIf EndIf EndIf GOLLOG("checked n° " & $conta1 & " users") Else GOLLOG("error in user search " & @error) EndIf _AD_Close() EndFunc ;==>loaduserS Func dataITA($inputdate) ; Input date in the format "YYYY/MM/DD[ HH:MM:SS]", and translates Tuesday 8 May 2018 -> Martedì 8 maggio 2018 - perla pearl Local $stringaDATAita = _DateTimeFormat($inputdate, 1) Select Case StringInStr($stringaDATAita, "Monday") $stringaDATAita = StringReplace($stringaDATAita, "Monday", "lunedi'") Case StringInStr($stringaDATAita, "Tuesday") $stringaDATAita = StringReplace($stringaDATAita, "Tuesday", "martedi'") Case StringInStr($stringaDATAita, "Wednesday") $stringaDATAita = StringReplace($stringaDATAita, "Wednesday", "mercoledi'") Case StringInStr($stringaDATAita, "Thursday") $stringaDATAita = StringReplace($stringaDATAita, "Thursday", "giovedi'") Case StringInStr($stringaDATAita, "Friday") $stringaDATAita = StringReplace($stringaDATAita, "Friday", "venerdi'") Case StringInStr($stringaDATAita, "Saturday") $stringaDATAita = StringReplace($stringaDATAita, "Saturday", "sabato") Case StringInStr($stringaDATAita, "Sunday") $stringaDATAita = StringReplace($stringaDATAita, "Sunday", "Domenica") EndSelect Select Case StringInStr($stringaDATAita, "January") $stringaDATAita = StringReplace($stringaDATAita, "January", "gennaio") Case StringInStr($stringaDATAita, "February") $stringaDATAita = StringReplace($stringaDATAita, "February", "febbraio") Case StringInStr($stringaDATAita, "March") $stringaDATAita = StringReplace($stringaDATAita, "March", "marzo") Case StringInStr($stringaDATAita, "April") $stringaDATAita = StringReplace($stringaDATAita, "April", "aprile") Case StringInStr($stringaDATAita, "May") $stringaDATAita = StringReplace($stringaDATAita, "May", "maggio") Case StringInStr($stringaDATAita, "June") $stringaDATAita = StringReplace($stringaDATAita, "June", "giugno") Case StringInStr($stringaDATAita, "July") $stringaDATAita = StringReplace($stringaDATAita, "July", "luglio") Case StringInStr($stringaDATAita, "August") $stringaDATAita = StringReplace($stringaDATAita, "August", "agosto") Case StringInStr($stringaDATAita, "September") $stringaDATAita = StringReplace($stringaDATAita, "September", "settembre") Case StringInStr($stringaDATAita, "October") $stringaDATAita = StringReplace($stringaDATAita, "October", "ottobre") Case StringInStr($stringaDATAita, "November") $stringaDATAita = StringReplace($stringaDATAita, "November", "novembre") Case StringInStr($stringaDATAita, "December") $stringaDATAita = StringReplace($stringaDATAita, "December", "dicembre") EndSelect Return ($stringaDATAita) EndFunc ;==>dataITA Func GOLLOG($logtext) ; Gollog V.2.3 gestione CRLF si o no ; gestione a capo automatico oltre i xx caratteri; gestione pulitura ogni totmila char Perla pearl ; basta aggiungere |nocrlf50 a fine stringa, dove 50 sono gli xx caratteri, conta la prima riga dove si supera quel limite. ; to declare $gollogcount = 0,$lastlog="sicrlf",$cachelog="",$guititle = "nomegui",$Gollogedit,$logfile = @ScriptDir & "\GOLLOG_LOG_", $months2NOTzip = 3 ; e anche le misure dell'edit: $geleft = 32, $getop = 32, $gewidth = 553, $geheight = 377 ; #include <File.au3> #include <GuiEdit.au3> #include <_zip.au3> ; to insert FUNCs: GOLLOG CLEANEDIT GOLzipZIP $gollogcount += StringLen($logtext) ;Local $logfile = @ScriptDir & "\GOLLOG_LOG_" ; now global Local $logfiletimerange = @YEAR & @MON Local $linelimit = StringRight($logtext, 2) If StringRight($logtext, 9) = "|nocrlf" & $linelimit Then $logtext = StringTrimRight($logtext, 9) Local $acapo = "no" Else Local $acapo = "si" $gollogcount += 4 If $gollogcount > 13000 Then Sleep(3000) cleanedit() ; MsgBox(64, "debug", $conta) $gollogcount = 0 EndIf EndIf If $acapo = "no" And (StringLen($cachelog) <= $linelimit) Then ;pearl perla non a capo se If $lastlog = "nocrlf" Then If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, $logtext) EndIf Else If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, @MDAY & "/" & @MON & "_" & @HOUR & ":" & @MIN & " " & $logtext) EndIf EndIf $cachelog = $cachelog & $logtext $lastlog = "nocrlf" Else If $lastlog = "nocrlf" Then If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, $logtext & @CRLF) EndIf $cachelog = $cachelog & $logtext _FileWriteLog($logfile & $logfiletimerange & ".txt", $cachelog) $cachelog = "" Else If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, @MDAY & "/" & @MON & "_" & @HOUR & ":" & @MIN & " " & $logtext & @CRLF) EndIf _FileWriteLog($logfile & $logfiletimerange & ".txt", $logtext) EndIf $lastlog = "sicrlf" EndIf EndFunc ;==>GOLLOG Func cleanedit() ; cleaning of edit every n° lines (in program put if $nlines > xlines then this function) GUICtrlDelete($Gollogedit) $Gollogedit = GUICtrlCreateEdit("", $geleft, $getop, $gewidth, $geheight) ;, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_BORDER)) GUICtrlSetData(-1, "" & @CRLF) GUICtrlSetFont(-1, 9, 800, 0, "consolas") GUICtrlSetColor(-1, 0090608) GUICtrlSetBkColor(-1, 0xF0DAE5) GUICtrlSetCursor(-1, 3) EndFunc ;==>cleanedit Func GOLzipLOG($months2NOTzip) ; zipping old log leaving unzipped only n months GOLLOG("Starting old logs zipping..") ; path extraction zone Local $logfiletimerange = @YEAR & @MON Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $arraylogpath = _PathSplit($logfile & $logfiletimerange & ".txt", $sDrive, $sDir, $sFileName, $sExtension) Local $logpath = $arraylogpath[1] & $arraylogpath[2] Local $hSearch = FileFindFirstFile($logfile & "*.txt") ; searching for logs Local $logconta = 0 While 1 ; single file processing cycle Local $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop Local $stringtime = StringTrimRight(StringRight($sFileName, 10), 4) ;obtaining year-month like 201609 If $logfiletimerange - $stringtime > $months2NOTzip Then ;zipping If Not FileExists($logfile & ".zip") Then If Not _Zip_Create($logfile & ".zip", 1) Then GOLLOG("Error " & @error & " creating " & $logfile & ".zip") Else GOLLOG("Created new log archive: " & $logfile & ".zip") EndIf Else GOLLOG("adding to archive: " & $logfile & ".zip") EndIf If Not _zip_additem($logfile & ".zip", $logpath & $sFileName) Then GOLLOG("Error " & @error & " zipping: " & $logpath & $sFileName) Else GOLLOG("Added: " & $logpath & $sFileName) $logconta += 1 If Not FileDelete($logpath & $sFileName) Then GOLLOG("ERROR - Unable to DELETE log file " & $logpath & $sFileName) EndIf EndIf EndIf WEnd GOLLOG("Finished = " & $logconta & " log files zipped") EndFunc ;==>GOLzipLOG Func CFGctrl() ; check ini files and load section names GOLLOG("checkin' INI file..|nocrlf50") If FileExists($inifile) Then $guiactive = IniRead($inifile, "general", "GUI", "?") If $guiactive = "?" Then GOLLOG("INI incomplete, missing section 'general', value GUI") ExitwithError() EndIf $flagITA = IniRead($inifile, "general", "dataITA", "?") If $flagITA = "?" Then GOLLOG("INI incomplete, missing section 'general', value dataITA") ExitwithError() EndIf $flagpwdLastSet = IniRead($inifile, "general", "pwdLastSet", "?") If $flagpwdLastSet = "?" Then GOLLOG("INI incomplete, missing section 'general', value pwdLastSet") ExitwithError() EndIf GOLLOG("reading section names...|nocrlf50") $arrayINIsections = IniReadSectionNames($inifile) GOLLOG("N°" & $arrayINIsections[0] - 1 & " groups to process") Else $message1 = "error: no saved settings !?" GOLLOG($message1) ExitwithError() EndIf GOLLOG("..completed") EndFunc ;==>CFGctrl Func CFGload($section) ; load single ini file section values $INIgroup = IniRead($inifile, $section, "group", "?") $INItomail = IniRead($inifile, $section, "tomail", "?") $INItosend = IniRead($inifile, $section, "tosend", "?") $INIdays1 = IniRead($inifile, $section, "days1", "?") $INIdays2 = IniRead($inifile, $section, "days2", "?") $INImailsubject = IniRead($inifile, $section, "mailsubject", "?") $INIsmpt = IniRead($inifile, $section, "smtp", "?") $INIfromname = IniRead($inifile, $section, "fromname", "?") $INIfromaddress = IniRead($inifile, $section, "fromaddress", "?") EndFunc ;==>CFGload Func ExitwithError() GOLLOG("**********ERROR and STOP****************") Exit EndFunc ;==>ExitwithError The example .ini: [group1] group=G_IT_PASSWORD_MONITORED days1=5 days2=2 tomail=yourgroup@yourdomain.it ;tosend=user; send mails to the domain user mail address, otherwise send to specified address tosend=0 ;tosend ;1 send mails, 0 disable mails for testing mailsubject=Domain users going to expire passwords smtp=smtp.your.own.server fromname=Password Expiration Guardian fromaddress=PEG@NSC.it [group2] group=G_IT_PASSWORD_NOTIFIED days1=5 days2=2 tomail=user ;tosend=user; send mails to the domain user mail address, otherwise send to specified address tosend=0 ;tosend ;1 send mails, 0 disable mails for testing mailsubject=Password is expiring ! smtp=smtp.your.own.server fromname=Password Expiration Guardian fromaddress=PEG@NSC.it [general] GUI=1 ;1 gui ON for testing, 0 gui disabled dataITA = 1 ;1 translates datetime in italian, 0 for ENG pwdLastSet = 0 ;1 tries to reset the 'pwdLastSet' attribute (you must have permissions), 0 do nothing
-
- domain
- activedirectory
-
(and 3 more)
Tagged with:
-
I played around a little with http://www.chilkatsoft.com/ ActiveX components. Here is an example based on examples from this page. #include <FileConstants.au3> #include <MsgBoxConstants.au3> ;~ http://www.chilkatsoft.com/downloads_ActiveX.asp ;~ http://www.chilkatsoft.com/support.asp ;~ http://www.chilkatsoft.com/refdoc/activex.asp ;~ http://www.chilkatsoft.com/refdoc/xChilkatCertStoreRef.html ;~ http://www.chilkatsoft.com/refdoc/xChilkatCertChainRef.html ;~ Email ActiveX Reference Documentation ;~ http://www.chilkatsoft.com/refdoc/xChilkatEmailRef.html ;~ http://www.example-code.com/vbscript/emailObj.asp ;~ http://www.example-code.com/vbscript/pop3.asp Global $_sPOP3_Server = 'xxxxxx' Global $_sPOP3_UserName = 'xxxxxx' Global $_sPOP3_Password = 'xxxxxx' _Example_1_Version() _Example_2_Get_number_of_mesages() _Example_3_Retrieve_UIDLs_from_POP3_Server() _Example_4_Save_Email_Attachments_to_Filesystem() Func _Example_1_Version() Local $oCrypt = ObjCreate("Chilkat_9_5_0.Crypt2") MsgBox(0, '', $oCrypt.Version) EndFunc ;==>_Example_1_Version Func _Example_2_Get_number_of_mesages() ; http://www.example-code.com/vbscript/pop3_mailboxCount.asp ; The mailman object is used for receiving (POP3) ; and sending (SMTP) email. ; This ObjCreate statement uses the new single-DLL ActiveX for v9.5.0 Local $oMailman = ObjCreate("Chilkat_9_5_0.MailMan") ; Any string argument automatically begins the 30-day trial. $success = $oMailman.UnlockComponent("30-day trial") If ($success <> 1) Then MsgBox(0, 'UnlockComponent', $oMailman.LastErrorText) Return EndIf ; Set the POP3 server's hostname $oMailman.MailHost = $_sPOP3_Server ; Set the POP3 login/password. $oMailman.PopUsername = $_sPOP3_UserName $oMailman.PopPassword = $_sPOP3_Password ; Get the number of messages in the mailbox. Local $iNumMessages = $oMailman.GetMailboxCount() MsgBox(0, '', $iNumMessages) EndFunc ;==>_Example_2_Get_number_of_mesages Func _Example_3_Retrieve_UIDLs_from_POP3_Server() ; Retrieve UIDL's from POP3 Server ; http://www.example-code.com/vbscript/pop3_getUidls.asp ; The mailman object is used for receiving (POP3) ; and sending (SMTP) email. ; This ObjCreate statement uses the new single-DLL ActiveX for v9.5.0 Local $oMailman = ObjCreate("Chilkat_9_5_0.MailMan") ; Any string argument automatically begins the 30-day trial. $success = $oMailman.UnlockComponent("30-day trial") If ($success <> 1) Then MsgBox(0, 'UnlockComponent', $oMailman.LastErrorText) Return EndIf ; Set the POP3 server's hostname $oMailman.MailHost = $_sPOP3_Server ; Set the POP3 login/password. $oMailman.PopUsername = $_sPOP3_UserName $oMailman.PopPassword = $_sPOP3_Password ; sa is a Chilkat_9_5_0.StringArray Local $oSA = $oMailman.GetUidls() Local $iCount = $oSA.Count For $i = 0 To $iCount - 1 ConsoleWrite($oSA.GetString($i) & @CRLF) Next EndFunc ;==>_Example_3_Retrieve_UIDLs_from_POP3_Server Func _Example_4_Save_Email_Attachments_to_Filesystem() ; Save Email Attachments to Filesystem ; http://www.example-code.com/vbscript/emailObject_saveAttachments.asp Local $oEmail = ObjCreate("Chilkat_9_5_0.Email") ; Load an email object containing attachments. ; This .eml can be downloaded from: ; http://www.example-code.com/testData/HtmlEmail.eml Local $sEML_FileFullPath = FileOpenDialog('Choose EML File', @ScriptDir, 'EML file (*.eml)', $FD_FILEMUSTEXIST) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") Return 0 EndIf Local $iSuccess = $oEmail.LoadEml($sEML_FileFullPath) If ($iSuccess <> 1) Then ConsoleWrite($oEmail.LastErrorText & @CRLF) Return 0 EndIf ; If OverwriteExisting is turned on, files with the same ; name are overwritten. If turned off, new/unique filenames ; are automatically generated. The filenames actually saved ; are accessible via the GetAttachmentFilename method. $oEmail.OverwriteExisting = 1 ; Save all attachments to the "myAttachments" subdirectory ; found under the calling process;s current working directory. ; This directory is automatically created if it does not already ; exist. $iSuccess = $oEmail.SaveAllAttachments("myAttachments") If ($iSuccess <> 1) Then ConsoleWrite($oEmail.LastErrorText & @CRLF) Return 0 EndIf ; List the attachment filenames: For $i = 0 To $oEmail.NumAttachments - 1 ConsoleWrite($oEmail.GetAttachmentFilename($i) & @CRLF) Next EndFunc ;==>_Example_4_Save_Email_Attachments_to_Filesystem Best regards mLipok
-
Hello I'm using the code below to send mails using our internal relay server. We got a Helpdesk system named Remedy. Our users can send us a mails using outlook 2010, and we'll get a ticket. The problem is if I send a mail using the above script our ticket system can't display unicode characters, like ex: Æ Ø Å. It will display them as: questionmarks: "? ? ?" inside our ticket system. In the outlook inbox it looks fine showing unicode symbols, but in our ticket system the unicode characters will be replaced by questionmarks. The thing is, if they send a mail using outlook, it works fine, but using the script above it doesen't. I tried to save my script with encoding: UTF-8 with BOM, but it didn't fix it. All suggestions are very welcome
-
-
Hello AutoIt community! I have a script that sends and email with attachments when I run the script. This script works perfectly. When I call that script from another script, it sends the email but does not include the attachment. Any idea why this would be happening? Thanks in advance!
-
Hi Guys, The attached script collects logs from various servers on my network, prints them into logs.txt, and emails them to me, daily. When I run the compiled script by clicking on the EXE it works beautifully. However, when it's run through the scheduler, I get an email with a blank txt file. This happens when I run the scheduled task manually and when it runs automatically. The SMTP part is from Jos, Thank you Jos. #region Logs retriever $log = "log.txt" If FileExists($log) Then FileDelete($log) EndIf RunWait(@ComSpec & " /c " & "psloglist.exe @servers.txt -d 1 -f we -r > " & $log, "", @SW_HIDE) #endregion ; ;################################## ; Include ;################################## #Include #region Logs retriever $log = "log.txt" If FileExists($log) Then FileDelete($log) EndIf RunWait(@ComSpec & " /c " & "psloglist.exe @servers.txt -d 1 -f we -r > " & $log, "", @SW_HIDE) #endregion ; ;################################## ; Include ;################################## #Include <file.au3> ;################################## ; Variables ;################################## $SmtpServer = "smtp.emailsrvr.com" ; address for the smtp-server to use - REQUIRED $FromName = "Logs" ; name from who the email was sent $FromAddress = "server@respondpower.com" ; address from where the mail should come $ToAddress = "tspitz@majorenergy.com" ; destination address of the email - REQUIRED $Subject = "Daily Server Logs" ; subject from the email - can be anything you want it to be $Body = "Warning and Error logs." ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = $log ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "server@respondpower.com" ; username for the account used from where the mail gets sent - REQUIRED $Password = "ab12cd34" ; 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 ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAILenables/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) 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) 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 If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;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 ;################################## ; Variables ;################################## $SmtpServer = "smtp.myserver.com" ; address for the smtp-server to use - REQUIRED $FromName = "Logs" ; name from who the email was sent $FromAddress = "server@myserver.com" ; address from where the mail should come $ToAddress = "tspitz@myserver.com" ; destination address of the email - REQUIRED $Subject = "Daily Server Logs" ; subject from the email - can be anything you want it to be $Body = "Warning and Error logs." ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = $log ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "server@myserver.com" ; username for the account used from where the mail gets sent - REQUIRED $Password = "mypassword" ; 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 ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAILenables/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) 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) 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 If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;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 Any ideas are greatly appreciated! Thanks in advance.