Domanda

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 !

È stato utile?

Soluzione

please try to execute this prior to your script :

$OutputEncoding = [Console]::OutputEncoding
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top