title: How to save my output results to .txt then send it as email attachment
body: <p>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 </p>
  
  <p>I have here my 1st part which is counting rows of csv </p>
  
  <pre><code>    $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+" ");  
  
  
   }
  </code></pre>