DrSeussFreak
Programmer
Each day a new file named 'bkuparcfiles_09062007.log' is produced, and I need to e-mail it to myself and a co-worker. The problem is that, as you see that their is a date at the end, and it changes each day. How can I pick the file that has been most recently modified?'
Code:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\adsmlogs\", _
ForReading)
SendEmail "To", "From", "MARS - Daily Tivoli Report", strSearchThis
Sub SendEmail(strTo, strFrom, strSubject, strMsg)
schema = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/"[/URL]
SmtpServer = "SMTP"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSubject
objEmail.Textbody = strMsg
objEmail.Configuration.Fields.Item (schema & "sendusing") = 2
objEmail.Configuration.Fields.Item (schema & "smtpserver") = SmtpServer
objEmail.Configuration.Fields.Item (schema & "smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End Sub