user3127554
user3127554

Reputation: 577

Powershell HTML doesn't format

I have a script in which I have the following line:

$body += "The file " + $item.Name + " is reaching $MaxSize GB! <br> Current Size: <b>" + $SizeInGb.ToString(".00") + " GB </b> <br />"+ "Path to file: " + $Path + "<br /> <br />" 

The problem is that my HTML doesn't get rendered/parsed (in Outlook)

My mail still shows as:

The file SRV20150818.VHD.ebxwyq is reaching 2 GB! <br> Current Size: <b>36,64 GB </b> <br />Path to file: \\srv641\Software G\update\ex\SRV565456.VHD.wyq<br /> <br />

Why is this?

The command I use to send my mail is:

Send-MailMessage -To "[email protected]" -From "[email protected]" -Subject $subject -Body $body -SmtpServer 192.168.16.18

Upvotes: 1

Views: 51

Answers (1)

Shawn Esterman
Shawn Esterman

Reputation: 2342

You need to include -BodyAsHtml in Send-MailMessage

Send-MailMessage -To "[email protected]" -From "[email protected]" -Subject $subject -Body $body -BodyAsHtml -SmtpServer 192.168.16.18

Upvotes: 5

Related Questions