I am trying to send email using the below function. On the email it comes without CSS.
Can anybody please help 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
↧
send email with CSS not working
↧