简体   繁体   中英

Sending email containing accent with powershell

I'm trying to send emails containing accents via powershell.

If i do the following :

$enc = [System.Text.Encoding]::UTF8
Send-MailMessage -to "Recipient@company.com" -from "Sender@company.com" -subject "test" -body "éèà" -Encoding $enc

It actually works and i get the accents fine in the mail.

BUT, if i do this :

$enc = [System.Text.Encoding]::UTF8

$Body = @"

éèà

"@

Send-MailMessage -to "Recipient@company.com" -from "Sender@company.com" -subject "test" -body $body -Encoding $enc

The email looks like this : éèÃ

I actually need to use the @" "@ quotes to send multiple lines mails.

Does anybody have a clue of how i could make this work ?

Thanks for your help !

请尝试在脚本之前执行此操作:

$OutputEncoding = [Console]::OutputEncoding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM