OK.. almost there.. the output.txt file is still somewhat incorrect in that it was incomplete...also it doesn't send email. Again, I'm sure it's something stupid. Any help appreciated
On Error Resume Next
dim dosendmail
set dosendmail= false
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objoutFile = objFSO.CreateTextFile("output.txt", True)
Set objServerlist = objFSO.OpenTextFile("servers.txt", 1)
Do Until objServerList.AtEndOfStream
strComputer = objServerList.ReadLine
strOldestFile = ""
dtmOldestDate = Now
Set objFolder = objFSO.Getfolder(strcomputer)
intFolderSize = Int((objFolder.Size / 1024) / 1024)
If intFolderSize > 1 Then
strOldestFile = ""
dtmOldestDate = Now
intFolderSize = Int((objFolder.Size / 1024) / 1024)
If intFolderSize > 1 and doSendmail = False Then
doSendMail=true
Set colFiles = objFolder.Files
For Each objFile in colFiles
strFile = objFile.Path
dtmFileDate = objFile.DateCreated
If dtmFileDate < dtmOldestDate Then
dtmOldestDate = dtmFileDate
strOldestFile = strFile
End If
Next
End If
objoutfile.writeline strcomputer & stroldestfile & ": " & dtmoldestdate
If DoSEndMail = True Then
Set myobj = CreateObject("Scripting.FileSystemObject")
const ForReading = 1
Set f = myobj.OpenTextFile("output.txt", ForReading)
ReadAllText = f.ReadAll
Dim objEmail
strEmailFrom = "from@email.com"
strEmailTo ="me@email.com"
strSubject ="TEST"
strMessage =strMessage & ReadAllText
Set objEmail = CreateObject("CDO.Message")
objEmail.From = strEmailFrom
objEmail.To= strEmailTo
objEmail.Subject = strSubject
objEmail.HTMLBody = strMessage
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"smtpaddress"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
End If
End If
Loop
I feel like I'm close.. Finally.