looking for a script to poll file date

June 9, 2010 at 11:30:15
Specs: Windows XP, intel 3.0/1gig
I need to poll a specific file for it's date and time and email me if the file is more than 24 hours old.

Any help or direction is appreciated.


See More: looking for a script to poll file date

Report •


#1
June 9, 2010 at 12:02:43
it's date and time
Files have three date/times associated with it: Created, Modified, and Accessed.

Report •

#2
June 9, 2010 at 13:15:05
The file is updated daily as part of a data extract, so I guess date and time modified is what I need.

Report •

#3
June 11, 2010 at 15:31:00
Apperently I answered a similar question about a year ago. Good thing I saved that script.

Let me know if it crashes; some combinations of Windows and MS Office tend to cause problems. (Different CDO.Messages have different interfaces.) If it does, I'll have to add some XML and wrap it in a Windows Script File.

'Note: Script assumes file to watch will be there. Script'll crash if it isn't.
Const watchName   = "some.file"
      timeout    = 1 'day
Const emailTo    = "whoever@someISP"
Const emailFrom  = "you@yourISP"
Const emailSbjct = "File untouched after 1 day"
Const SMTPServer = "ssmtp.yourISP"
Const SMTPPort   = 25
Const emailUsr   = "you@yourISP"
Const emailPsswd = "yourEmailPassword"
Const emailSSL   = False
      emailMsg   = "Issues w/ " & watchName


With CreateObject("Scripting.FileSystemObject").GetFile(watchName)
  emailMsg = emailMsg & vbNewLine & "Mod: " & .DateLastModified
  If .DateLastModified < (Now - timeout) Then _
    SendEmail
End With

Sub SendEmail
  Const cfg = "http://schemas.microsoft.com/cdo/configuration/"
  With CreateObject("CDO.Message")
    .From                                  = emailFrom
    .To                                    = emailTo
    .Subject                               = emailSbjct
    .TextBody                              = emailMsg
    With .Configuration.Fields
      .Item(cfg & "sendusing")             = 2
      .Item(cfg & "smtpserver")            = SMTPServer
      .Item(cfg & "smtpserverport")        = SMTPPort
      .Item(cfg & "smtpconnectiontimeout") = 60
      .Item(cfg & "smtpauthenticate")      = 1
      .Item(cfg & "smtpusessl")            = emailSSL
      .Item(cfg & "sendusername")          = emailUsr
      .Item(cfg & "sendpassword")          = emailPsswd
      .Update
    End With
    .Send
  End With
End Sub


Report •

Related Solutions


Ask Question