I need to create a report with the Headers color coded as in the screenshot. I want to assign #00FFFF to $Array_Good and #FF00FF to $Array_Bad. I believe I can do a conditional style-sheet, but I am not able to get it to work. I have specified th.good and tf.bad in the stylesheet but I am unsure how to call them using CLASS.
$Sr_No = 1
$Incident = "INC12345"
$Date_Submit = (Get-Date).ToString("MM/dd/yyyy")
$Client_Alias = "E9yu027"
$Access = "Full"
$MbxEmail = "smbx@testp.com"
$SnowIncident = "4657748"
# Set the style for the email
$CSS = @"
<Style>
table { margin: auto; font-family: Brandon Grotesque; border-collapse: collapse; }
table, th, td { border: 1px solid #E3E3E3; }
th.good{background: #00FFFF; color: #000000; max-width: 400px; padding: 5px 10px;}
th.bad{background: #FF00FF; color: #000000; max-width: 400px; padding: 5px 10px;}
td { font-size: 12px; padding: 5px 20px; color: #000; }
tr { background: #fff; }
<⁄style>
"@
$Array_Good = @()
$Line_Good = (@{N="Initialize"}).N | Select @{N="Sr";E={$Sr_No -join ";"}},
@{N="Incident";E={$Incident -join ";"}},
@{N="Date Submitted";E={$Date_Submit -join ";"}},
@{N="Client Alias";E={$Client_Alias -join ";"}},
@{N="Access";E={$Access -join ";"}},
@{N="Mbx Email";E={$MbxEmail -join ";"}},
@{N="Snow Incident";E={$SnowIncident -join ";"}}
$Array_Good += $Line_Good
$Array_GoodHtml = ($Array_Good | ConvertTo-Html -Fragment)
$Array_BadHtml = $Array_GoodHtml
$Body = @()
$Body += $CSS
$Body += '<font size="4" face="Brandon Grotesque" >Shared Mailbox Access Successfully Granted:</font>'
$Body += "<br>"
$Body += $Array_GoodHtml
$Body += "<br><br>"
$Body += '<font size="4" face="Brandon Grotesque" >Problem granting access to Shared Mbx. Helpdesk Submitter to resolve:</font>'
$Body += "<br>"
$Body += $Array_BadHtml
$Body += "<br><br>"
$Body_Final = $Body -join "`n" #convert to multiline string
Send-MailMessage -To $ToAddress -From $FromAddress -Subject $mailSubject -body $Body_Final -SmtpServer relay.server.com -BodyAsHTML
