Results 1 to 5 of 5

Thread: [RESOLVED] Email when files in multiple folders exist aged 15min or older

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    3

    Resolved [RESOLVED] Email when files in multiple folders exist aged 15min or older

    I have a list of directories that get files added to by other users on my network.

    I would like a script (triggered by scheduled task) that would detect if there are files in these folders older than 15 minutes, and send me an email.

    I am able to run Batch/DOS, Python, Perl, or VBS - I have them all installed on the server. As long as they can be triggered from Scheduled task.

    Example:
    C:\UsersFTP\JoeS\FromCustomer\ <files dropped here>
    C:\UsersFTP\Mark\FromCustomer\ <files dropped here>
    C:\UsersFTP\Robbie\FromCustomer\ <files dropped here>
    C:\UsersFTP\Tammy\FromCustomer\ <files dropped here>

    - Check every 15 mintues if any FILES exist in these directories (along with 50 more).
    - It should ignore folders.
    - If No, quit.
    - If yes, email [email protected] and notify that files are waiting to be reviewed.
    - The scheduled task can run it every 15 minutes.
    - I would like it to only send ONE email, no matter how many files are waiting.

    Example notification: (the XX are variables)

    = = = = =
    From: [email protected]
    To: [email protected]
    Subject: Files in FromCustomer are waiting


    You Have files that are waiting since xx:xx:xx PM (over XX minutes).

    The files are located in:

    C:\UsersFTP\Tammy\FromCustomer\
    C:\UsersFTP\Robbie\FromCustomer\

    Please process or remove them. Thank you.

    = = = = =

    I have been looking at doing this in Batch, but I just don't think it is capable... I was hoping to use VB, but i am limited in my education on it - i can read and understand what it does, i can't quite write it yet. Thoughts, help?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Email when files in multiple folders exist aged 15min or older

    If you can't write VB code then the first order of business would be to learn how to write VB code. It's not really for us to write your code for you but any help we provide otherwise will be of limited use until you do that. To that end, I'd suggest starting here:

    http://www.homeandlearn.co.uk/net/vbnet.html

    As for the code, you can create a DirectoryInfo object for your folder and then call its GetFiles method to get an array of FileInfo objects representing the files in the folder. You can loop through that and use the appropriate property to determine how old the file is by comparing that to the current time. You can send an email using the System.Net.Mail.MailMessage class. I'm quite sure you would find examples of its use on the web.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    3

    Re: Email when files in multiple folders exist aged 15min or older

    I thank you for your candor with regard to your suggestion about my need for education. I can assure you, I am investigating that option.

    As for the code being written by someone else - I posted this with the hopes that the basics had been written to some variant already, and that a VB script writer of more experience would be willing to share, and not force me to reinvent the wheel. It was not my intention to 'pimp out' the work.

    As I have seen in this forum, others have asked similar questions regarding functions and scripts - I was merely doing the same. It also appeared that this was a friendly place in which to get the help I was looking for. The cynicism and disdain in the initial reply was rather disheartening.

    While you seem unwilling to help with this effort, I will simply offer thanks to your pointers, and note that I have been researching the bits and pieces in an attempt to put together this myself.

    It should also be noted that I have been working on this in other languages (currently python) - but was offering up this post to see if VB was a viable and simpler option.

  4. #4
    Addicted Member
    Join Date
    Apr 2011
    Posts
    223

    Re: Email when files in multiple folders exist aged 15min or older

    Reading your first post, it looks to me that you're requesting someone either code or help you code in VBS? Or do you mean VB.Net?

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    3

    Re: [RESOLVED] Email when files in multiple folders exist aged 15min or older

    I was able to successfully piece together the code as of this posting. Thank you for those who replied, the pointers were taken into consideration.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width