我正在使用PowerShell发送SMTP邮件。邮件的正文来自文件。
问题是,当我收到这封邮件时,它会删除所有空格和换行符,所以看起来很丑陋。
Outlook客户端不会删除换行符。
我的代码如下:
$smtpserver = "smtpserver"
$from="email1@domain.com"
$to="email2@domain.com"
$subject="something"
$body= (Get-Content $OutputFile )
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
$msg.IsBodyHTML = $true
$mailer.send($msg)
我甚至尝试使用带有-encoding ASCII和其他参数的get-content,但没有帮助。请问有人能帮忙吗?
-
谢谢。