Powershell HTML 不格式化

use*_*554 1 powershell parsing html-parsing

我有一个脚本,其中包含以下行:

$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 />" 
Run Code Online (Sandbox Code Playgroud)

问题是我的 HTML 没有被渲染/解析(在 Outlook 中)

我的邮件仍然显示为:

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 />
Run Code Online (Sandbox Code Playgroud)

为什么是这样?

我用来发送邮件的命令是:

Send-MailMessage -To "test@ds.test" -From "tesbetest@test.test" -Subject $subject -Body $body -SmtpServer 192.168.16.18
Run Code Online (Sandbox Code Playgroud)

Sha*_*man 5

您需要包含-BodyAsHtml在 Send-MailMessage 中

Send-MailMessage -To "test@ds.test" -From "tesbetest@test.test" -Subject $subject -Body $body -BodyAsHtml -SmtpServer 192.168.16.18
Run Code Online (Sandbox Code Playgroud)