send email with CSS not working
i trying send email using below function. on email comes without css.
can please me
function sendemail { param([string] $body) $smtpserver = "mailhost.lsg" $smtpfrom = "serverstats@noreply.lsg.com" $smtpto = "asif@lsg.com" # $messagesubject = "monitoring domain replication & health issues" $message = new-object system.net.mail.mailmessage $smtpfrom, $smtpto $message.subject = $messagesubject $message.isbodyhtml = $true $message.body = (get-content c:\temp\html.html | out-string) $smtp = new-object net.mail.smtpclient($smtpserver) $smtp.send($message) } # end function sendemail $workfile = repadmin.exe /showrepl * /csv $results = convertfrom-csv -inputobject $workfile $results = $results | select "source dsa", "naming context", "destination dsa" ,"number of failures", "last failure time", "last success time","last failure status" | convertto-html -cssuri c:\temp\style.css $results | out-file "c:\temp\asif.html" $style='<style type="text/css"> #header{font-family:"trebuchet ms", arial, helvetica, sans-serif;width:100%;border-collapse:collapse;} #header td, #header th {font-size:14px;border:1px solid #98bf21;padding:3px 7px 2px 7px;} #header th {font-size:14px;text-align:left;padding-top:5px;padding-bottom:4px;background-color:#a7c942;color:#fff;} #header tr.alt td {color:#000;background-color:#eaf2d3;} </style>' $body= $style + $results $body | out-file c:\temp\html.html sendemail $body
hi asif,
please try this:
$body= $style + $results $body | out-file c:\temp\html.html $body1= (get-content c:\temp\html.html) | out-string sendemail $body1
if have misunderstanding, please let me know.
best regards,
anna
Windows Server > Windows PowerShell
Comments
Post a Comment