This Script will Send a PSObject or other Object from PowerShell in a table format, using a HTML email.

The main point of this script is that it applies HTML formatting using a Cascading Style Sheet (CSS).

Once this script has been configured it then becomes very easy to send email reports in the "Pretty table format".

Just call the cmdlet with the mandatory parameters: InputObject, To & Subject.


$FileInfo = Get-ChildItem -Filter *.xls | Select-Object Name, Length

Send-HTMLEmail -InputObject $FileInfo -To -Subject "Directory Information"


You will receive the following table in the body of the email.


I updated this script to now include the CSS embedded in a here-string, or else you can send in the link to the file.

I previously used the CSS shown below, however you do not need that anymore.

You can download and save the CSS file and update the script with the location if you want to customize the CSS format rather than use the default embedded CSS.



Send an email with an object in a pretty table 
Send email 
.PARAMETER InputObject 
Any PSOBJECT or other Table 
The Subject of the email 
The To field is who receives the email 
The From address of the email 
This is the Cascading Style Sheet that will be used to Style the table 
.PARAMETER SmtpServer 
The SMTP relay server 
PS C:\> Send-HtmlEmail -InputObject (Get-process *vmware* | select CPU, WS) -Subject "This is a process report" 
An example to send some process information to email recipient 
NAME        :  Send-HtmlEmail 
VERSION     :  1.1.0    
LAST UPDATED:  01/03/2013 
AUTHOR      :  Milo 
function Send-HTMLEmail { 
#Requires -Version 2.0 
               Position = 0, 
               HelpMessage="Please enter the Inputobject")] 
               Position = 1, 
               HelpMessage="Please enter the Subject")] 
               Position = 2, 
               HelpMessage="Please enter the To address")]     
    [String[]]$To = "", 
    [String]$From = "",     
    [String]$SmtpServer ="" 
   )#End Param 
if (!$CSS) 
    $CSS = @" 
Please download the code from the link rather than copy from here, since the code does not show up here. 
}#End if 
$HTMLDetails = @{ 
    Title = $Subject 
    Head = $CSS 
$Splat = @{ 
    To         =$To 
    Body       ="$($InputObject | ConvertTo-Html @HTMLDetails)" 
    Subject    =$Subject 
    SmtpServer =$SmtpServer 
    From       =$From 
    BodyAsHtml =$True 
    Send-MailMessage @Splat