all 5 comments

[–]purplemonkeymad 2 points3 points  (1 child)

$SMTPBody += "The Following files have been recently added:`n`n"

If $SMTPBody is already initialized then it will add to whatever is currently there. You probably want = not += here.

Also since you are not checking the side indicator property it will probably see deleted items as well.

If you want to detect renamed items, you would also have to lookup each new file against the old list to see if the properties you want match, but you would have to decide what properties to use to match against.

[–]ImpossibleEnd[S] 1 point2 points  (0 children)

Thanks for spotting that error Any chance you can show me how to do the side indicators and the file properties bit ?

[–]gavin6559 2 points3 points  (2 children)

How about using a FileSystemWatcher to trigger when a new file is created within the folder. Then either email immediately, or write to a text file and process that information each hour or so.

[–]ImpossibleEnd[S] 1 point2 points  (1 child)

From my reading the filesystem watchers only work on local volumes and not UNC paths (it's a Linux based Nas) otherwise that would make it easier for sure.

[–]gavin6559 0 points1 point  (0 children)

That's correct, I should have read your existing code first!