使用Powershell发送包含重音符号的电子邮件 [英] Sending email containing accent with powershell

查看:116
本文介绍了使用Powershell发送包含重音符号的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Powershell发送包含重音符号的电子邮件。

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

如果我执行以下操作:

$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.

但是,如果我这样做:

$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 ?

感谢您的帮助!

推荐答案

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

please try to execute this prior to your script :

$OutputEncoding = [Console]::OutputEncoding

这篇关于使用Powershell发送包含重音符号的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆