Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29927

How to save my output results to .txt then send it as email attachment

$
0
0

im newbie in powershell but happy to explore it. I have some question currently i got sample scripts that count number of rows to a target csv file but my next job would be save it to a file either CSV or text file then send it as email attachment

I have here my 1st part which is counting rows of csv

    $fileEntries = [IO.Directory]::GetFiles("\\servername\folder\folder2");    foreach($fileName in $fileEntries) {  $count = 0 $filedate = (Get-Date).Date $reader = New-Object IO.StreamReader $filename while($reader.ReadLine() -ne $null){$count++}    $reader.close()   #Get-Content $filename | %{$lines++}  [Console]::Writeline($filename+""+$count+"");   }

Viewing all articles
Browse latest Browse all 29927


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