title: Sending Formatted HTML email
body: <p>I have a text file <strong>output.txt</strong> which has following content:</p>
  
  <pre><code>OPERATINGSYSTEM     PROJECTSERVER1   PROJECTSERVER2
  Windows                       1.36             4.42
  Linux12                       2.78             5.76
  MacOS                         3.45             6.39
  Ubuntu                        4.12             0.00
  Android                       0.00             3.46
  FreePhysicalMemory           30.12            31.65
  TotalVisibleMemorySize       48.00            48.00
  CPULoadPercentage                2                4
  </code></pre>
  
  <p>I want to send content of <strong>output.txt</strong> in a email as a body in Formatted HTML table look in <strong>Windows server 2008 R2</strong>. I am trying with below code, but its not working for me..where am I mistaking below ?</p>
  
  <pre><code>$smtpServer = "sunny@abc.com"
  $smtpFrom = "process@abc.com"
  $smtpTo = "administrator@abc.com"
  $messageSubject = "Servers Memory"
  
  $message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
  $message.Subject = $messageSubject
  $message.IsBodyHTML = $true
  
  $message.Body = Get-Content C:\Logs\output.txt
  $style = "&lt; style&gt;BODY{font-family: Arial; font-size: 10pt;}"
  $style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
  $style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
  $style = $style + "TD{border: 1px solid black; padding: 5px; }"
  $style = $style + "&lt; /style&gt;"
  
  $smtp = New-Object Net.Mail.SmtpClient($smtpServer)
  $smtp.Send($message)
  </code></pre>
  
  <p><strong>EDIT1</strong></p>
  
  <p>When i modified my code as below:</p>
  
  <pre><code>$smtpServer = "sunny@abc.com"
  $smtpFrom = "process@abc.com"
  $smtpTo = "administrator@abc.com"
  $messageSubject = "Servers Memory"
  
  $message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
  $message.Subject = $messageSubject
  $message.IsBodyHTML = $true
  
  $style = "&lt;style&gt;BODY{font-family: Arial; font-size: 10pt;}"
  $style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
  $style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
  $style = $style + "TD{border: 1px solid black; padding: 5px; }"
  $style = $style + "&lt;/style&gt;"
  $message.Body = "&lt;head&gt;&lt;pre&gt;$style&lt;/pre&gt;&lt;/head&gt;"
  $message.Body += Get-Content C:\Logs\output.txt
  
  $smtp = New-Object Net.Mail.SmtpClient($smtpServer)
  $smtp.Send($message)
  </code></pre>
  
  <p>I am getting mail like this:</p>
  
  <pre><code>OPERATING SYSTEM SERVER1 SERVER2 Windows 1.36 4.42 Linux 2.78 5.76 MacOS 3.45 6.39 Android 0.00 3.46 Ubuntu 4.12 0.00 FreePhysicalMemory 30.12 31.65 TotalVisibleMemorySize 48.00 48.00 
  </code></pre>
  
  <p><strong>Note: I am using Powershell v1.0</strong></p>