I have to send email immediately to all users when user upload files in to the folder. My existing code works as follows: we have the Task Scheduler which will run daily at 11am and the files will filter modified date. My aim is to send email when user upload files but cannot run the Scheduler for 1 hour or for every 5 min because the modified date is file created date not the upload date. In the folder below is the code can anyone help me to update the code so that users can receive immediately.
Dim objFso
Set objFso = CreateObject("Scripting.FileSystemObject")
Dim strPath, yr, mnt
yr = CStr(Year(Now))
mnt = CStr(Month(Now))
strPath = "c:\\users\upload files\email " + yr
Dim strContent
strContent = ""
Set objFolder = objFso.GetFolder(strPath)
For Each objFile In objFolder.Files
If objFso.GetExtensionName (objFile.Path) = "pdf" Then
If objFile.DateLastModified > dateadd("hr", -24, Now) Then
strContent = strContent + "<li>" + _
"<a href=""C://Users/uploadfiles/email/" + yr + "/" + _
objFile.Name + """>" + objFile.Name + "</a></li>"
MsgBox(strContent)
End If
End If