powershell - Script to send new files via email from monitored folder -


i'm wondering if can point me in direction of how automate sending of newly added files located in monitored folder via email (exchange), ideally without outlook installed on server.

i use scripts daily notify me of changes in watched folder via email, none of these attach files on email, , @ best list new files names etc.

we have software outputs 3 small text files @ same time day, has email manually same external address each day. i'd automate process.

i'm running server 2008 r2, , don't mind powershell , vb etc. appreciated.

thank you.

this should going.

 $watchpath = "c:\folder\"  $sendtolist = @("touser@domain.com") $sendfrom = "fromuser@domain.com" $emailsubject = "file '{0}' changed" $smtphost = "smtp.server"  $watcher = new-object system.io.filesystemwatcher  $watcher.path = $watchpath $watcher.includesubdirectories = $false $watcher.enableraisingevents = $true  $changed = register-objectevent $watcher "changed" -action {       send-mailmessage -smtpserver $smtphost -to $sendtolist -from $sendfrom -subject ($emailsubject -f $eventargs.name) -attachments $eventargs.fullpath  }  

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -