I have this code that will basically read a filename, filesize and last update date and then email the results (scheduled on a daily basis)
Dim fso, f1, f2
'Set the file attrribute to append
Const ForWriting = 8
Set fso = CreateObject("Scripting.FileSystemObject")
' Get a File object to query.
set f1 = fso.GetFile("\\stm-adm2\schematic\uploads\Versus.20071203.csv")
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "db_montor_srvr@stm-adm2.olntv.com"
objEmail.To = "jrichardson@versus.com"
objEmail.Subject = "IT Operations Status Report - AFF web site File Compare"
objEmail.Textbody = f1.name & " " & f1.Size & " " & f1.DateLastModified & " "
'& vbcrlf & vbcrlf & _
'== remote smtp configuration
objEmail.Configuration.Fields.Item _
(" = 2
'Name or IP of Remote SMTP Server
objEmail.Configuration.Fields.Item _
(" = "192.168.0.50"
'Server port (typically 25)
objEmail.Configuration.Fields.Item _
(" = 25
objEmail.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objEmail.Send
This code works fine but my problem is that the Filename that I am reporting on changes everyday!!!! Today the filename is filename.20071203.csv
and tomorrow it will be filename.20071204.csv and so on....
How can I report on this file is the name changes everyday???
Thinking that I could use a wildcard character for the filename but that didn't work...
Can I change my code to simple look at the contents on the directory where the file lives and report on the contents? if so how??
any help would be much appreciaTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dim fso, f1, f2
'Set the file attrribute to append
Const ForWriting = 8
Set fso = CreateObject("Scripting.FileSystemObject")
' Get a File object to query.
set f1 = fso.GetFile("\\stm-adm2\schematic\uploads\Versus.20071203.csv")
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "db_montor_srvr@stm-adm2.olntv.com"
objEmail.To = "jrichardson@versus.com"
objEmail.Subject = "IT Operations Status Report - AFF web site File Compare"
objEmail.Textbody = f1.name & " " & f1.Size & " " & f1.DateLastModified & " "
'& vbcrlf & vbcrlf & _
'== remote smtp configuration
objEmail.Configuration.Fields.Item _
(" = 2
'Name or IP of Remote SMTP Server
objEmail.Configuration.Fields.Item _
(" = "192.168.0.50"
'Server port (typically 25)
objEmail.Configuration.Fields.Item _
(" = 25
objEmail.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objEmail.Send
This code works fine but my problem is that the Filename that I am reporting on changes everyday!!!! Today the filename is filename.20071203.csv
and tomorrow it will be filename.20071204.csv and so on....
How can I report on this file is the name changes everyday???
Thinking that I could use a wildcard character for the filename but that didn't work...
Can I change my code to simple look at the contents on the directory where the file lives and report on the contents? if so how??
any help would be much appreciaTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!