最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

email - Powershell send-MailMessage to include trademark in the body - Stack Overflow

programmeradmin3浏览0评论

My PS script is sending email but changes the trademark and registered symbol to a question mark.

$body = "<b>A program™ has sent this email® . </b>"

Send-MailMessage -smtpServer mail  -Subject "test" -BodyAsHtml  $body 

Output is A program? has sent this email? .

How can I get the symbols in the output email?

My PS script is sending email but changes the trademark and registered symbol to a question mark.

$body = "<b>A program™ has sent this email® . </b>"

Send-MailMessage -smtpServer mail  -Subject "test" -BodyAsHtml  $body 

Output is A program? has sent this email? .

How can I get the symbols in the output email?

Share Improve this question asked Feb 17 at 10:22 Ko NayakiKo Nayaki 861 silver badge11 bronze badges 2
  • Try adding -Encoding UTF8 to Send-MailMessage – Mathias R. Jessen Commented Feb 17 at 10:25
  • 1 The issue might be already in the $Body due to an unexpected terminal / console encoding. Try: $OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding first, see: Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10) – iRon Commented Feb 17 at 10:32
Add a comment  | 

1 Answer 1

Reset to default 3

Easiest wasy to fix this: because you are sending a HTML body you can simply replace the symbols with &copy; for © and &trade; for ™.

发布评论

评论列表(0)

  1. 暂无评论