send alert when files exists in a dir

  • I guess I am having a brain cramp here. I have process that when successful will remove all files from a certain directory. Is there a way at a certain scheluded time to run a job against a directory to return a value if there is a file and notify me via email?

  • Yes, u can just put this code in activeX script in DTS package and assign the global variables "FilesFoundMail" and "FilesNotfoundMail" to execut SQL task using dynamic properites task. And schedule the job as u need. This will send the email accordingly..but before that

     

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set f = fso.GetFolder(DTSGlobalVariables("FilePath").value)

     Set s = f.Files

    if not isempty(s) and not isnull(s)  Then

      

     DTSGlobalVariables("FilesFoundMail").Value="xp_sendmail @recipients = 'rec@gmail.com',

       @message = 'Files are found on the Dir.',

       @copy_recipients = 'anned;michaels',

       @subject = 'FilesFound' "

     Else

      DTSGlobalVariables("FilesNotfoundMail").Value="xp_sendmail @recipients = 'rec@gmail.com',

       @message = 'Files are not found on the Dir.',

       @copy_recipients = 'anned;michaels',

       @subject = 'FilesNotFound' "

     

     End if

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply