'VBscript sends an email when an item is detected in specified folder . 'NOTES! 'When Script runs it works in infinite cycle! You can use it in GFI MAX RMM as Automated Task. 'Script Requires CDO, (Outlook) . 'Script sends an email when an Item in specified folder is detected 'Requires CDO, (Outlook) EmailSubject = "Email Failure Notification" EmailBody = "simple text email that can be viewed in any email client. " 'Can change it to anyting Notification text . Const EmailFrom = "mail@gmail.com" Const EmailFromName = "My Very Own Name" Const EmailTo = "mail" Const SMTPServer = "smtp.gmail.com" Const SMTPLogon = "username" Const SMTPPassword = "Password" Const SMTPSSL = True Const SMTPPort = 465 Const cdoSendUsingPickup = 1 'Send message using local SMTP service pickup directory. Const cdoSendUsingPort = 2 'Send the message using 1SMTP over TCP/IP networking. Const cdoAnonymous = 0 ' No authentication Const cdoBasic = 1 ' BASIC clear text authentication Const cdoNTLM = 2 ' NTLM, Microsoft proprietary authentication ' First, create the message Set objMessage = CreateObject("CDO.Message") objMessage.Subject = EmailSubject objMessage.From = """" & EmailFromName & """ <" & EmailFrom & ">" objMessage.To = EmailTo objMessage.TextBody = EmailBody ' Second, configure the server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPLogon objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SMTPSSL objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objMessage.Configuration.Fields.Update Set filesys = CreateObject("Scripting.FileSystemObject") Do While 1=1 'infinite cycle Set DataFolder = filesys.GetFolder("Program Files\GFI\MailEssentials\EmailSecurity\FailedMails") 'Path to Directory Set DataFiles = DataFolder.Files Dim i If (i > datafiles.count)Then i=i-1 end if if (datafiles.count > i) Then objMessage.Send a= datafiles.count end if Loop If err.number <> 0 Then WScript.Echo ("Script Check Failed") Wscript.Quit 1001 Else Wscript.Echo "Successfully Passed" wscript.Quit(0) End If