Вопрос

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 !

Это было полезно?

Решение

please try to execute this prior to your script :

$OutputEncoding = [Console]::OutputEncoding
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top