Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pinging a Folder

Status
Not open for further replies.

SymbionA

IS-IT--Management
Apr 16, 2007
45
AU
I want to ping a folder every 5 mins to see if a file exists, if a file has been dropped in a folder I want to email the file automatically.

I have the routine to email an attachment, however, I am not sure how to ping a folder to check if a files exists?

Could somebody advise on how this can be done?

Thanks in advance.
 
you could stick a timer on a form and have it run something like the following:

Code:
    Dim fso As New FileSystemObject
    Dim flds As Folders

    
    Set flds = fso.GetFolder("C:\").SubFolders

       If flds.Item("Windows").Files.Count > 0 Then
            MsgBox "send email!"
        End If

Code simply counts the number of files in a specified folder.

Cheers

Nick
 
Should have mentioned that in order to make this work you will have to make reference to "Microsoft Scripting Runtime" Tools > References.

Nick
 
It is also possible to use Dir:

[tt]If Dir("C:\Data\TheFile.txt")<>"" Then
'File found[/tt]
 
Thank you for your response.

OK, so will it be permanent loop?

So for example, it finds a file, mails the file, removes the file and when another file is dropped into the folder it will mail the file, remove the file etc.?

Thanks again!
 
You can use the Timer event and Timer Interval, as NickDel mentioned.
 
Thanks!

Well, unfortunately, I am new to Access. I have looked around for Timer Event and I cannot see in Access how to use it.

I want to call a function "SendEmail" every 5 mins, however, I am unsure how I structure the code to do this or whether I need a form to do it.

Would you help ?

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top