Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

need help expanding script to be more robust

$
0
0

  I need this script to process selective file types from a supplied folder(parm) and then
after processing file move to archive folder and continue processing with a log of files processed. WHen I gather the info
it needs to send an email before processing next file.

$sender
$subject
$body

  The script here is basic but the concept will read from a folder and pickup files *.mai then email content $body to that
user $sender with the $subject. You could find the word END in those data rows but it needs to only quit when it finds the END
in column 1 and that will be the last END it finds in the file.

$txt = @'<WHO:Jim<SUBJECT:Email Test
Then just rows and rows of Text data that may have part of the word end...
...
...
END
'@

$sender=[regex]::Match($txt,'(?<=<WHO:\s*).*').Value
$subject=[regex]::Match($txt,'(?<=<SUBJECT:\s*).*').Value
$body=[regex]::Match($txt,'(?s)(?<=<SUBJECT:.*?\r\n).*(?=\r\nEND(\r\n|$))').Value

$sender
$subject
$body

Thanks.

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>