【发布时间】:2018-08-27 21:33:20
【问题描述】:
如何让 Send-MailMessage 在邮件正文中添加新行? 一个单独的 PowerShell 脚本会生成一些文件,我将内容读入一个变量并将其作为正文发送,如下所示:
$fileContent = Get-Content -Path $file | Out-String
Send-MailMessage -BodyAsHtml -Body $fileContent -From $f -SmtpServer $s -To $t -Subject $s -Verbose
$fileContent 当前将具有
`r`n
字符。当您打开文件时,它有新的行。但是当我转换为字符串并发送电子邮件时,它全部在一行上。我试过这样替换:
$fileContent -replace "`r`n","<br />"
$fileContent -replace '`r`n','`r`n`r`n`r`n'
如果有人可以帮助我将非常感激,谢谢!
【问题讨论】:
标签: powershell