Send-MailMessage发送邮件遇到乱码???


PowerShell交流中心分类: Powershell基础Send-MailMessage发送邮件遇到乱码???
0
xbin530 asked 9年 ago

通过send-mailmessage发送由get-content命令读取txt文件的内容时,文本文件中的中文字符不能被正确识别,显示为?号,难道要用英文版的powershell才能正常??
不好意思,又来麻烦大家了……。!先谢过……。

powershell 命令

$b =Get-Content D:\t.txt 
 Send-MailMessage -to aaa@aaa.com  -from aaa@aaa.com -Subject tewst -Body "$b" -SmtpServer email.xmc.wh

通过send-mailmessage发送出来后就变成下面这样的了,中文件全变成了?号,版面也被完全打乱了。

Remove-Item : Access to the path 'D:\windows\Exchange - ??' is denied. ???? ?:2 ??: 6 + $t | Remove-Item -Recurse -ErrorAction: Continue 2> d:\t.txt +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : PermissionDenied: (D:\windows\Exchange - ??:String) [Remove-Item], UnauthorizedAccessException     + FullyQualifiedErrorId : RemoveItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.RemoveItemCommand
1 Answers
1
Best Answer
Mooser Lee 管理员 answered 9年 ago

Get-Content -Encoding
Send-MailMessage -Encoding
都是支持指定编码的,你可以使用UTF-8

xbin530 replied 9年 ago

多谢指教!