HTML output to Email Body

I would like to make the html file as the body of the email. But when I’m trying to add that as the body, its kinda like a text file only. Is there’s a way to put that as is (tabled, with color , etc).

###HTML Report####
$css = @"
<style>
<HTML><TITLE>EMC Data Capacity Report</TITLE><BODY>
h3, h5, th { text-align: left; font-family: Segoe UI; }
table { margin: auto; font-family: Segoe UI; box-shadow: 10px 10px 5px #888; border: thin ridge grey; }
th { background: #0046c3; color: #fff; max-width: 400px; padding: 5px 10px; }
td { font-size: 11px; padding: 5px 20px; color: #000; }
tr { background: #b8d1f3; }
tr:nth-child(even) { background: #dae5f4; }
tr:nth-child(odd) { background: #b8d1f3; }
</style>
"@


$Object | ConvertTo-Html -Head $css -Body "

EMC MirrorView Report (ABU DHABI to DUBAI)

`n
Generated on $(Get-Date)
" | Out-File "C:\Temp\Mirrors\Mirror_SABUPVNX01_$Logtime.html" $body = Get-Content -Path "C:\Temp\Mirrors\Mirror_SABUPVNX01_$Logtime.html" -Raw send-MailMessage -SmtpServer $smtp -To $to -From $from -Attachment $attachment -Subject "EMC MirrorView Report_$Date" -BodyasHtml -Body $body -Priority high

Here is the output of the email

h3, h5, th { text-align: left; font-family: Segoe UI; } table { margin: auto; font-family: Segoe UI; box-shadow: 10px 10px 5px #888; border: thin ridge grey; } th { background: #0046c3; color: #fff; max-width: 400px; padding: 5px 10px; } td { font-size: 11px; padding: 5px 20px; color: #000; } tr { background: #b8d1f3; } tr:nth-child(even) { background: #dae5f4; } tr:nth-child(odd) { background: #b8d1f3; }
h3, h5, th { text-align: left; font-family: Segoe UI; } table { margin: auto; font-family: Segoe UI; box-shadow: 10px 10px 5px #888; border: thin ridge grey; } th { background: #0046c3; color: #fff; max-width: 400px; padding: 5px 10px; } td { font-size: 11px; padding: 5px 20px; color: #000; } tr { background: #b8d1f3; } tr:nth-child(even) { background: #dae5f4; } tr:nth-child(odd) { background: #b8d1f3; }

EMC MirrorView Report (ABU DHABI to DUBAI)
Generated on 05/08/2019 04:55:46
MirrorView Name Sync Progress(%) Previous Update Ended
DUB-C2_SRMTEST01_L251 100 5/8/2019 3:47:59
DUB-C2_SYS02_L1 0 5/7/2019 17:30:19
DUB-C2_FC_LRP_SYS09_WK10 100 Not Available
DUB-C2_FC_LRP_SYS11_WK10 100 Not Available
DUB-C2_FC_LRP_SYS10_WK10 100 Not Available
DUB-C2_SYS03_L2 0 5/8/2019 3:26:11
DUB-C2_FC_LRP_SYS12_IDL 100 Not Available
ABU-C2_SYS03_L102 100 5/8/2019 3:45:31
DUB-C2_SYS01_L0 0 5/8/2019 3:26:56
DUB-C2_FC_LRP_SYS08_WK10 100 Not Available
DUB-C2_SYS06_L5 0 5/8/2019 3:18:05
ABU-C2_SYS02_L101 100 5/8/2019 3:43:05
ABU-C2_SYS06_L105 10 5/8/2019 3:41:26
ABU-C2_SYS05_L104 100 5/8/2019 3:50:58
DUB-C2_SYS07_L10 0 5/8/2019 3:26:51

I believe CSS won’t be rendered in the mail client. Which mail client are you using ?

What do you mean which mail client?

Who you are viewing the mail ? I know outlook will not render CSS.

I used the following to get html in the body of a message:

It looks like you’re outputing to an html file, which I dont think you need to do…