当用户将文件上传到该文件夹时,我必须立即向所有用户发送电子邮件。我现有的代码如下工作:我们有任务计划程序,它将在每天上午11点运行,文件将过滤修改日期。我的目的是在用户上传文件时发送电子邮件,但无法运行调度程序1小时或每5分钟,因为修改日期是文件创建日期而不是上载日期。在下面的文件夹中,代码可以帮助我更新代码,以便用户可以立即收到。
$scope.$parent.selectedItem = .....
答案 0 :(得分:1)
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and TargetInstance.GroupComponent= 'Win32_Directory.Name=""c:\\\\scripts""'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop
对于每10秒创建一次的文件(within 10
),它监视c:\ scripts(注意反斜杠必须加倍,然后再加倍)。
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "dc@gmail.com"
emailObj.To = "dc@gmail.com"
emailObj.Subject = "Test CDO"
emailObj.TextBody = "Test CDO"
emailObj.AddAttachment "c:\windows\win.ini"
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Username"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Done"