Send email as HTM
hi,
created html report supposes send task scheduler once month,
this content:
$body = $a = "<style>" $a = $a + "body{background-color:peachpuff;}" $a = $a + "table{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}" $a = $a + "th{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}" $a = $a + "td{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}" $a = $a + "</style>" get-distributiongroup | where-object { (get-distributiongroupmember –identity $_.name).count –eq 0 } | select name,managedby,primarysmtpaddress | convertto-html -head $a -body "<h3>empty distribution list</h3>" send-mailmessage -from "meir@microsoft.com" -to meir@microsoft.com -subject $sub -smtpserver "smtp@microsoft.com" -body $body
as can see stated -body $body should consist htm content,
why not working?
my website:www.pelegit.co.il mcitp /mcsa 2012
hi meir,
sorry, forgot convertto-html returned each line separately. here's fixed version:
$a = @" <style> body{background-color:peachpuff;} table{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;} th{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle} td{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod} </style> "@ # get-distributiongroup | where-object { (get-distributiongroupmember –identity $_.name).count –eq 0 } | select-object name, managedby, primarysmtpaddress | $body = (convertto-html -head $a -body "<h3>empty distribution list</h3>") -join "`n" send-mailmessage -from "xxx" -to "xxx" -subject "empty distribution list" -smtpserver "xxx" -body $body -bodyashtml
as "why not?":
- if mean $body = then it's because doesn't thing
- if mean building header: manually adding each line cumbersome , cannot changed. using notation can edit html header in favorite html editor , paste code (and same later changes).
cheers,
fred
there's no place 127.0.0.1
Windows Server > Windows PowerShell
Comments
Post a Comment