Advertisement

05.09.2008 at 05:52AM PDT, ID: 23389084
[x]
Attachment Details

VBscript to notify if files added to a folder

Asked by barrykeel in VB Script, Microsoft Operating Systems

Tags: Microsoft, Server 2003

I need a script to notify me if files are added to a folder. I have gotten some code form the Microsoft site and modified it.The original code displayed a message box that you would click off of. It worked fine. I substituted code for the sending of the email. It works as well only the email loops and continuously sends emails. I need the email to send and the stop yet have the script continue to run to monitor the folder. This is what I have so far.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\dropbox""'")

Do
 

Dim objMessage
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "New Files Have Been Added"
objMessage.From = "newfiles@yourdomainname.com"
objMessage.To = "user@yourdomain.com"
objMessage.TextBody = "You have new files in the folder foldername."
 

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "yourmailserver.com"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

objMessage.Send


Loop Start Free Trial
[+][-]05.09.2008 at 06:01AM PDT, ID: 21532309

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, Microsoft Operating Systems
Tags: Microsoft, Server 2003
Sign Up Now!
Solution Provided By: MoreHeroic
Participating Experts: 4
Solution Grade: A
 
 
[+][-]05.09.2008 at 06:01AM PDT, ID: 21532311

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 06:02AM PDT, ID: 21532319

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 06:08AM PDT, ID: 21532368

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 06:09AM PDT, ID: 21532383

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 06:11AM PDT, ID: 21532394

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 06:14AM PDT, ID: 21532405

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 06:14AM PDT, ID: 21532413

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628