title: Powershell send file as attachment of a mail
body: <p>I need to check if a file exist into a path.</p>
  
  <p>if yes, I need to send it as attachment of mail.</p>
  
  <p>this my code now:</p>
  
  <pre><code>$file='STREAM_preg.txt'
  $pathfile ='c:\Users\root\Desktop'
  $dest ='C:\Users\root\Desktop\test'
  
  cd $pathfile
  if(Test-Path $file){
          $datestamp = get-date -uformat "%Y%m%d%H%M"
      Copy-Item $file $dest\$datestamp"_"$file
      $new_file = echo $datestamp"_"$file
      echo $new_file
        # Send-MailMessage -SmtpServer xxxxxxxxxx -To pluto@pippo.com -From preg_new_stream@pippo.com -Subject "test mail" -Body "file name is: $new_file"
  }else{
          echo false
  }
  </code></pre>