On Error Resume Next
'the searching part of your code works fine.
Dim strPath
Dim blnFound
pstrDir = "C:\"
Set fso = CreateObject("Scripting.FileSystemObject")
strPath = Dir(pstrDir & "\*.*")
While Len(strPath) > 0 And Not blnFound
If Day(FileDateTime(pstrDir & "\" & strPath)) = Day(Now) Then
blnFound = True
End If
strPath = Dir()
Wend
'Now what are you doing here? Why are you giving
'CheckForTodaysFile the blnFound value?
CheckForTodaysFile = blnFound
'Then when you use your if statment it seems like you are
'calling the function CheckForTodaysFile with a string
'parameter. What does CheckForTodaysFile do?
If CheckForTodaysFile("M:\monitor\edi\edi\dump") Then
Set refoutlook = CreateObject("outlook.application")
sendmail = 1
If Err <> 0 Then
sendmail = 0
End If
On Error GoTo 0
' do usefull stuff
emaildata = ("The Releases have not been loaded today. Please check their status and resolve!")
If sendmail = 1 Then
Set refmailitem = refoutlook.createitem(0)
'I was using my email here to be testing it.
refmailitem.Subject = "New Realeses have not been loaded.Please Check!!"
refmailitem.body = emaildata
refmailitem.send
Set refmailitem = Nothing
Set refoutlook = Nothing
End If
End If