title: PowerShell e-mail - sending .csv in body with HTML
body: <p>I have a powershell script that runs a mysql query, and exports the output to a .csv file.</p>
  
  <p>It then imports it, sends it to a <code>$body</code> variable and e-mails it.</p>
  
  <p>Here is the code</p>
  
  <pre><code>### Script to write body of e-mail to $body variable ###
  
  $body = @"
  CHECK 4A - MONTH DATABASE REPORT
  
  Row count should be between 3-4k, but less on a Monday.
  
  "@  + (Import-CSV  C:\Users\*****\Documents\Reports\result4A.csv | Out-String)
  </code></pre>
  
  <p>I want to use a bit of HTML in the e-mail too, just to make it a bit easier to read, so I used the <code>-BodyAsHtml</code> parameter:</p>
  
  <pre><code>### Send e-mail ###
  
  send-mailmessage -from " Daily Check &lt;server@company.com&gt;" -to "Admin &lt;e-mail@company.com&gt;" -BodyAsHtml -subject "Daily Server Checks Report" -body "$body" -priority High -dno onSuccess, onFailure -smtpServer **.*.*.**
  </code></pre>
  
  <p>The problem is that this means the .csv file isn't displayed correctly in the e-mail, as the e-mail body is changed to HTML. Is there any way around this? I would like to keep the export to .csv solution if possible.</p>