I have three files with the following names:
m.csv, tt.csv, and sp.csv
Those files are generated on daily basis in C:\test and moved to an archive folder.
I need a VB Script which to do the following:
1-Check if the files exist in C:\test (Be careful, the loop cannot be by count>0 as We have other files in C:\test
2-Check if the date modified of the files is equal of today.
3-If one of those conditions is not met:
The script need to run the following notification code (I want a unique .vbs (loops+notification)
' Send by connecting to port 25 of the SMTP server.
Const cdoSendUsingPort = 2
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' Set the CDOSYS configuration fields to use port 25 on the SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ""
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
' Build HTML for message body.
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<p>-----This message has been sent automatically-----<p>"
strHTML = strHTML & "Hello,</br><p>Csv files haven't been generated today,</b> please check the interface.</p>"
strHTML = strHTML & "<p>Regards,</p>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
' Apply the settings to the message.
Set .Configuration = iConf
.To = "" 'ToDo: Enter a valid email address.
.From = "" 'ToDo: Enter a valid email address.
.Subject = "[WARNING] Csv files for CC haven't been generated today"
.HTMLBody = strHTML
' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
1-Log name: log-files-checks.txt
2-If the folder in which the script check the files don't exist log file should contains Now & "The folder" & variable doesn't exist
3-If one of the files m.csv, tt.csv, and sp.csv" doesn't exist log file file should contains Now & “ERROR”: ” & ": One of the following files "m.csv, tt.csv, and sp.csv" hasn't been found
4-If datemodified of one of the file is not equal of today Now & “ERROR” & “the following files : m.csv, tt.csv, and sp.csv" has a datemodified equal of today
4-If the notification is sent the log file should contain Now & "ERROR: Notification has been sent."
5-If the files are in the folder with a date modified of today the log file should contains Now “SUCESS: All is good files exist in the folder and the datemodified is equal of today notification hasn’t been sent”